Skip to content

Entity type characteristics

Describes how to enhance entity types with additional functionality.

When defining an entity type, the functionality of the entities can be enhanced with additional characteristics. Examples include entities that have a published/unpublished status, or a timestamp that gives the time they were last modified.

These characteristics are provided by an interface, which the entity's own interface should inherit from, in addition to \Drupal\Core\Config\Entity\ConfigEntityInterface or \Drupal\Core\Entity\ContentEntityInterface.

Some characteristics also provide a trait for the entity class. This has implementations of the interface's methods, and may also have a helper method for \Drupal\Core\Entity\FieldableEntityInterface::baseFieldDefinitions() which defines base fields that the trait expects to store data. Furthermore, trait methods may expect certain entity keys to be set: see the documentation for each trait for details.