Module Development

ContentEntityType Attribute: Properties Reference for Drupal 11

This reference document contains a detailed list of available properties for the #[ContentEntityType] attribute in Drupal 11. The current documentation in the Drupal 11 code base lists, but doesn't always describe, each of these properties. Or, in many cases, the property is an associative array where the nested key/value pairs are important, but what they should be isn't well documented. So we've created this helpful reference. Most of the properties listed here will also apply to #[ConfigEntityType] attributes. These properties define the metadata and behavior of custom entity types.

In this tutorial, we'll:

  • Look at an example of how to use #[ContentEntityType] attributes.
  • Provide a comprehensive list of available properties and a description of each.
  • Show detailed examples of using nested array properties like handlers[].

By the end of this tutorial, you should be able to understand how and when to use any of the properties of a #[ContentEntityType] attribute in order to modify the behavior of a custom entity type.