Search code examples
phptypo3backend

TYPO3 extension: Is the __construct() of a class only called when the record is created via the FE, not the BE?


A rather theoretical question:

Currently i'm working on a TYPO3 extension. This extension consists of a rather complex tree structure where the creation of a specific object/record leads to the creation of specific objects/records of other classes that are then attached to the Object Storages of this "main" class. The logic behind the creation of the Object Storages and the creating and attaching of the other classes is placed in the constructor of that "main" class. In the frontend new records and the complete hierarchical structure are created flawlessly, but when i create the record of the "main" class in the BE, the other objects aren't created.

So is the __construct() of a class only called when the object is created in the frontend via an Action of its controller?


Solution

  • The construct of your domain model class is only called in an extbase construct.

    That means:

    • TCA (List-View of the BE) => no call of __construct
    • Usage in an extbase controller in an BE-Module => call of __construct
    • Usage in an extbase controller in an FE-Module => call of __construct