[TYPO3-english] Constructor injection not working after serializing+deserializing an object?
David Bruchmann
david.bruchmann at gmail.com
Sat Jul 18 14:22:24 CEST 2015
Using __construct in extbase is usually not advised.
Instead you should use initializeObject(), initializeAction(), or
initializeYourActionName().
Sometimes you even never need those functions as some basics are already
setup anyway.
Have a look in the classes you extend.
Maybe this helps to verify the extbase-jungle:
http://www.lobacher.de/files/cs/ExtbaseFluidCheatSheet_3.02_pluswerk.pdf
Date: Sat, 18 Jul 2015 01:05:09 +0200
> From: Jan Kornblum <jan.kornblum at gmx.de>
>
> Hi newsgroup,
>
> after serializing and deserializing an object, constructor injection
> doesn't seem to work:
>
> class MyClass {
> public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManager
> $objectManager) {
> $this->objectManager = $objectManager;
> }
> public function __sleep() {
> $this->objectManager = null;
> return array_keys(get_object_vars($this));
> }
> }
>
> $myObject = $this->objectManager->get('\MyClass');
>
> DebuggerUtility::var_dump($myObject);
> ->> $myObject->objectManager exists.
>
> DebuggerUtility::var_dump(unserialize(serialize($myObject)));
> ->> $myObject->objectManager is always null.
>
> What am i missing?
>
> Kind regards, Jan
>
More information about the TYPO3-english
mailing list