Persistence · Question 7 of 12
Which method does Extbase call after a model object has been loaded from the database, so that you can initialise ObjectStorage properties there, for example?
1 answer is correct. Easy
Show answer
Answer
- A initializeObject()
Explanation
When loading from the database, Extbase does not call the constructor: the DataMapper creates the object with the library doctrine/instantiator and sets the values directly. It then calls initializeObject(). The recommendation is therefore: put initialisations such as $this->speakers = new ObjectStorage(); into initializeObject() and also call this method from the constructor – that way the property is set both for new Conference() and for loaded objects. Relying on the constructor alone is the typical trap. initializeAction() belongs to the controller and runs before every action, not when a model is loaded.