Entity type characteristics

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/entity.api.php \entity_type_characteristics
  2. 10 core/lib/Drupal/Core/Entity/entity.api.php \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.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 645

Interfaces

Title Sort descending File name Summary
EntityChangedInterface core/lib/Drupal/Core/Entity/EntityChangedInterface.php Defines an interface for entity change timestamp tracking.
EntityOwnerInterface core/modules/user/src/EntityOwnerInterface.php Defines a common interface for entities that have an owner.
EntityPublishedInterface core/lib/Drupal/Core/Entity/EntityPublishedInterface.php Provides an interface for access to an entity's published state.
RevisionableInterface core/lib/Drupal/Core/Entity/RevisionableInterface.php Provides methods for an entity to support revisions.
RevisionLogInterface core/lib/Drupal/Core/Entity/RevisionLogInterface.php Defines methods for an entity that supports revision logging and ownership.
TranslatableInterface core/lib/Drupal/Core/Entity/TranslatableInterface.php Provides methods for an entity to support translation.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.