Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Überblick

Alle Entitäten werden in der Module.xml des jeweiligen Moduls definiert. Zusätzlich gibt eine PHP Klasse, die auf die Entität verweist und von BaseEntity erbt. Es wird das Active-Record-Pattern verwendet. 

Relationen 

...

Overiew

The data model of a module is specified in the Module.xml file present in the modules directory. This concept was developed when Model-To-Code was all the latest rage, but instead of creating (and having to constantly update) code from the model derived from the module config, Nostromo makes use of PHP’s magic methods to dynamically set and get values of the model. This happens in the BaseEntity class from which all data classes need to inherit. The approach to persistence is a mix of the Active Record pattern and the Mapping pattern. Queries are automatically generated based on the model of entity (more in line with the Mapping pattern) but the methods to manipulate data (like load, save and delete) are found in the entities class which is a corner stone of the Active Record Pattern.

Every field in a entity does have a type. These types are not limited to what the database offers. Due to this fact there are fields like markdown, money or birthday, that are mappend to the correct database data types automatically.

Relations

Relations between different entities can also be specified in the Module.xml file. If you access a relation by its name the related entity is lazy loaded. However this approach does not feature autocompletion in the IDE, which is why we create getter methods for relations most of the time. If you specify lookup fields in an entity those are loaded together with the entities data by default, resulting in inner join SQL statements. This enables you to create domain objects not limited to their corresponding data tables.