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

g4-lisz at tonarchiv.ch g4-lisz at tonarchiv.ch
Fri Apr 25 13:25:58 CEST 2014


Hi Stephan,

thank you for your help. I finally got the injection of ObejctManager
working. I didn't realize that I have to inject the
ObjectManager_Interface_, and that there is a new option "flush system
cache", which has to be enabled for the BE user.

Hence I don't need __construct() or initializeObject() anymore.
But __construct() still doesn't get called at all for this object. Even
if I delete all caches. Strange...

BR
Till

On 04/23/2014 12:45 PM, Stephan Schuler wrote:
> Ah, and here's another one.
>
> You should avoid t3lib_div::makeInstance and use the objectManager->get instead. T3lib_div::makeInstance reuses singletons if they already exist. So it's perfectly fine to use t3lib_div::makeInstance to reach out for the objectManager itself. But t3lib_div::makeInstance doesn't trigger any dependency injection (not injecting settings, not calling inject* methods, not analyzing @inject annotations) mechanisms. ObjectManager->get does.
> So always use objectManger->get, never t3lib_div::makeInstance.
>
>
> Stephan Schuler
> Web-Entwickler
>
> Telefon: +49 (911) 539909 - 0
> E-Mail: Stephan.Schuler at netlogix.de
> Website: media.netlogix.de
>
>
>
> -----------------------------
> Citrix Netscaler: Schneller, besser, weiter
> Erfahren Sie, wie Sie Applikationen für den mobilen Gebrauch sicher und einfach bereitstellen. Jetzt anmelden zum netlogix-Event am 29.04.2014:
> http://it-training.netlogix.de/angebote/events/citrix-netscaler
> ------------------------------------
>
>
>
> --
> netlogix GmbH & Co. KG
> IT-Services | IT-Training | Media
> Neuwieder Straße 10 | 90411 Nürnberg
> Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
> E-Mail: info at netlogix.de | Internet: http://www.netlogix.de
>
> netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
> Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
> Umsatzsteuer-Identifikationsnummer: DE 233472254
> Geschäftsführer: Stefan Buchta, Matthias Schmidt
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: typo3-dev-bounces at lists.typo3.org [mailto:typo3-dev-bounces at lists.typo3.org] Im Auftrag von Popy
> Gesendet: Mittwoch, 23. April 2014 11:40
> An: List for Core-/Extension development
> Betreff: Re: [TYPO3-dev] Model Class __construct() never called
>
> Probably because the object is not constructed
>
>
> Cordialement,
> Pierre Dudoret
>
>
> 2014-04-21 23:15 GMT+02:00 <g4-lisz at tonarchiv.ch>:
>
>> 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
>> _______________________________________________
>> TYPO3-dev mailing list
>> TYPO3-dev at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
>>
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev




More information about the TYPO3-dev mailing list