Nearly every major component that makes up a Drupal site is an entity of one type or another, e.g. users, nodes, and blocks are all types of entities. All entities can then be customized by adding fields to them. Understanding how Drupal's Entity system works is fundamental to understanding the similarities and differences between the main components that make up a Drupal site. You can alter existing entity types to make them work more efficiently for your site, and it's also possible to create your own entity types to encapsulate the behavior of specific data structures within your application.
In Drupal, entity is a general concept that represents a noun (person, place or thing). Out of the box, there are a number of different types of entities in Drupal, each meant to represent a specific type of data.
One type of entity is a user. A user entity contains information that is specific to people that visit our site, such as the user's email address and password. Within the concept that entities represent nouns, a user entity is a person.
Another entity type in Drupal is content (sometimes called a node) entity. Content entities contain data that is relevant for a something that is expected to be visited and consumed, such as a URL path, title, and body. Continuing with the concept that entities represent nouns, a content entity is a place. It has a URL and can be visited and it contains content that is meant to be consumed by a visitor.
Additionally, each content entity in Drupal has an owner. The owner (often referred to as the author) of a specific piece of content is a user entity. Most often the owner of some content is the user that created the content. Continuing with our analogy of a user representing a person and content representing a place, then it makes sense that a person would own a place. This concept of a user entity owning a content entity is a relationship. And that relationship is made practical in our site by the use of entity reference fields.
- Understand what components of a Drupal site are entities
- Understand the difference between configuration and content entities
- Know when, and how to create custom entities
The Entity API is stable core API.
Entities and fields are closely related and the boundaries between the two are often confused. It’s generally a good idea to learn both in order to properly use either one.
Entity API (guide) (Drupal.org)
- Drupal Entity API documentation guide on Drupal.org.
Entity API topic overview (api.drupal.org)
- Technical documentation for the Entity API. Useful when you already understand the concept of entities but are unsure how to implement a feature or accomplish a specific task.
Example for Developers (Drupal.org)
- The examples project contains example modules with code that demonstrates creating both content and configuration entities.