[TYPO3-dev] Model Class __construct() never called

g4-lisz at tonarchiv.ch g4-lisz at tonarchiv.ch
Mon Apr 21 23:15:21 CEST 2014


On 04/21/2014 09:18 PM, Steffen Müller wrote:
> Hi.
>
> On 21.04.2014 00:33 g4-lisz at tonarchiv.ch wrote:
>> There's one strange thing: One of the model class its __construct()
>> method gets nerver called, even if some instances are successfully loaded.
>> I also put a die(...) into the construct method - no effect!
>>
> I guess that happens when objects are reconstituted with unserialize().
>
> Solution: Use the method initializeObject() instead of __construct()
>
> unserialize() triggers the __wakeup() method of a model, which is
> inherited from
> \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject::__wakeup()
>
> "If a method with the name initializeObject() exists, it is called after
> all dependencies have been injected and configured; so you can use this
> method for further initialization work." [1]
Hi Steffen,

thanks for the reply.

Something is weird with this class. Injection didn't work, neither. I
wanted to inject the ObjectManager. But the @inject notation didn't do
anything. Then I put a makeInstance(ObjectManager) into __contruct(),
but the objectManager property was still NULL afterwards.

Any idea why all this doesn't work?

Cheers,
Till



More information about the TYPO3-dev mailing list