Drupal entities – the building blocks of the data model

Web Hosting

Drupal website

What is an entity? Merriam-Webster defines an entity as “something that exists by itself”. Developers using languages such as C# or Java will be familiar with Objects. Database analysts will know an entity as a real-world object represented in a database. But what is meant by Drupal entities?

Drupal introduced the concept of entities in Drupal 7, replacing the need for awkward Custom Fields. In Drupal 8, entities came of age and are now the building blocks of the data model for both content and configuration. When learning Drupal basics its essential to get a thorough grasp of entities. Here we take a look at Content and Configuration entities in Drupal, what they are and how they are used.

Content and configuration entities

Although Drupal refers to both of these as entities, they are quite different. In Drupal 8, a configuration entity is used to store the information for the site’s configurable settings, such as image styles and user roles.

A content entity is piece of content data, such as a node, taxonomy or block. Once an entity has been created with data input, it is known as an instance of the entity type.

The Entity types have sub-types, allowing for variations in their behaviour. For example, a content item may have sub-types of basic page and vendor page.


Bundles are used as containers for sub-types of an entity, this allows for a common set of fields for the entity type, but additional fields for sub-types. For example, the node entity has bundles for its sub-types such as article, blog post and page. All node entities will have fields such as title and author, but the article sub-type would have a tag field.


Fields are added to content entities to make up the detail of the data model. Drupal has a large range of core field types: Boolean, number fields such as integer, float and decimal, image and text fields. These can be extended with custom field types.


A plugin is a design pattern that allows a developer to code different functionality for different modules. The plugin appears the same to the code that uses it – it adheres to the interface for the plugin type – but executes code relevant and unique to the module.


Annotations are PHP code comments used to define metadata about a class or function. They allow plugins to be “discovered” when loading the classes for an entity type. For example, an annotation for the block class would contain an @Block tag. The block manager will discover this custom block and make it available.


Handlers are Drupal 8’s upgrade from Drupal 7’s controllers. They provide a flexible way of handling API pieces. By using handlers, subsystems can be built in a pluggable way. They help administrators to manage storage and access control and the forms needed for creating and updating entities.

Drupal Summary

In Drupal 8, entities are the building blocks of the data model. When learning Drupal basics, it’s vital to understand that everything is an entity. Entities all have values and properties, which gives a cohesive development method. By understanding the relationships between entity types, fields and bundles, we can make the most of Drupal’s development environment.

If you need hosting for your Drupal website, you’ve landed in the right place. Grab your hosting here.