entity
) which is persisted to the data storage layer of the application. Model classes are home to any business logic that is specific to a single entity. Operations in the model should not perform database queries or one-off business operations. Instead, they should be composed of helper functions to designed to simplify common operations (e.g formatting the entity's fields or building data structures from the entity).@Entity()
- Identifies the class as a doctrine entity.@InheritanceType("SINGLE_TABLE")
- Enable single table inheritance for the object. This allows child modules to easily extend this entity.@Table(name="sa_users")
- Sets the name of the table where the will be stored. If the table does not already exist, it can be created by updating the doctrine schema. The table names of siteadmin modules should be prefixed with sa_
as shown in the example. Custom modules should be prefixed with a project specific prefix of your choice. Try to keep it under 5 characters.protected
scope. Specific use cases may require private
scope, but to enforce data integrity public
scope is not acceptable under any condition.@Id
and @GeneratedValue
annotations). An exception will be thrown if one is not defined.helper method
performs business logic that only affects the current entity (or associated entity). All database queries should be performed in a corresponding repository. In the context of the example below, the User
entity may add/remove posts, format its own data, or prepare data structures from its own data. It should not affect the state of other entities.