Module Development

Concept: Custom Entity Types for Drupal 8, 9, and 10

Drupal's Entity API enables us to define custom content entity types. It provides a structured approach to store custom data. Creating a custom entity makes sense when built-in entity types like nodes or taxonomy terms don't meet the specific requirements of a project. Custom entities allow for custom data structures, and use Drupal's core features such as access control, Views integration, and JSON:API support. Using the Entity API to create custom content entities ensures your custom data will be compatible with other Drupal modules.

In this tutorial, we'll:

  • Discuss use cases for custom content entities.
  • Get a high-level overview of defining a custom entity type.
  • Provide additional resources where you can learn more about defining custom entity types.

By the end of this tutorial, you'll understand the use case for custom content entities and how to begin defining one.

Drupal Module Developer Guide