codefog / contao-haste

Haste is a collection of tools and classes to ease working with Contao
http://codefog.pl/extension/haste.html
MIT License
42 stars 24 forks source link

Pass a real DCA object to the save callbacks #75

Closed leofeyer closed 8 years ago

leofeyer commented 8 years ago

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.

leofeyer commented 8 years ago

The change does not work if there is no bound model, therefore I'm closing the PR again.

Toflar commented 8 years ago

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.

aschempp commented 8 years ago

Correct would be to have an interface :blush:

leofeyer commented 7 years ago

I think it would work like this (see https://github.com/contao/core-bundle/issues/886):

$dc = (new \ReflectionClass('DC_Table'))->newInstanceWithoutConstructor();
qzminski commented 7 years ago

@aschempp @Toflar this solution looks good to me and it's available since 5.4. Any objections?

Toflar commented 7 years ago

It's not a good solution, I think 😄

qzminski commented 7 years ago

Well certainly not the perfect one but I think pretty satisfying in the reality we have.