Code-Driven Content Modelling with Drupal 8


In Drupal 7 the Content Modelling part of the development process usually happens primarily in the user interface:

  • You create a new content type
  • You add and configure the fields you need
  • You configure the view modes (often using contributed modules such as Display Suite or Entity view modes)

At some point down the road, however, you need to write some custom code. Maybe you need fine-grained access logic or you need to display information in a way that the generic formatters do not cover. So often enough you end up with some of the logic in the user interface and some of it in code.

While Drupal 8 makes managing fields from the user interface all the more powerful, the underlying APIs make it convenient to define an entity type in code from start to end. This greatly improves not only the developer experience when dealing with entities but also maintainability, reusability and performance.

What to expect

In this workshop I will live-code an entity type (almost) from scratch. At the end of those 45 minutes we will have the following:

  • A custom access controller
  • A form adding and editing entities with configured widgets
  • The database storage for our entity type
  • The rendered output of an entity with configured formatters.

And all that without touching the user interface! ...and with a ridiculously little amount of code!

The code I will use as a starting point and also some example code of what I will write can be seen in my sandbox on

Note: This workshop will be similar to the workshop I did in Szeged.

Experience level: 
All Levels
Session Type: 
Hands-on Lab
Session topics: 

Lead Partners

Partners Spotlight