Closed leofeyer closed 8 years ago
The change does not work if there is no bound model, therefore I'm closing the PR again.
Yeah, I had that issue as well. We could try providing a dummy DummyDataContainer extends DataContainer
class which could solve this issue but I don't feel like this is the correct way either.
Correct would be to have an interface :blush:
I think it would work like this (see https://github.com/contao/core-bundle/issues/886):
$dc = (new \ReflectionClass('DC_Table'))->newInstanceWithoutConstructor();
@aschempp @Toflar this solution looks good to me and it's available since 5.4. Any objections?
It's not a good solution, I think 😄
Well certainly not the perfect one but I think pretty satisfying in the reality we have.
This will prevent "Argument 2 passed to … must be an instance of Contao\DataContainer, instance of stdClass given" exceptions if the save callback has a type hint for a DataContainer object.