[TYPO3-mvc] Dependency injection on object unserialization
Jan Kornblum
jan.kornblum at gmx.de
Mon Jul 27 13:34:37 CEST 2015
Hi Helmut,
>> Am i right with my assumption, that all kinds of dependency injection
>> (@inject annotation, injectAnyhing() method, constuctor injection)
>> don't work when an object gets unserialized?
>
> This is correct.
>
>> And, if so, are there plans to change this behaviour in future extbase
>> version?
>
> Why change a correct behavior?
> To unserilaize an object, it must have been serialized before, right? Before
> it was serialized it was created with the object manager and the dependencies
> got injected. So (in theory) the serialized state should have the
> dependencies injected already.
But the serialized state shouldn't contain objects like an
ObjectManager, ObjectStorage<AnyChildObjects> or any deeper nested
objects. Thats why i throw them away on serialization.
> If you remove the dependencies during serialisation, you must take care
> adding them again when unserlializing.
O.K., thats what im doing so far...
> What Objects do you want to (un-)serilialize anyway?
I want to serialize a basket object (containing products with
categories assigned and so on) and on serialization of the products i
throw anything away but their uid and unserialization it restore the
rest manually.
Therefore it would be more comfortable if dependency injection would
work on unserialization, but i understand your theory ;)
Thanks a lot!
Kind regards, Jan
More information about the TYPO3-project-typo3v4mvc
mailing list