Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

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.

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.