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.

Certifications & exams

Which exam comes next?

You can already practise for 19 exams, and 21 are up for a vote. See all certifications with their official information, cast your vote or suggest your exam.

See all certifications