Fieldable Entities, TypedData and DataDefinitions: How to Work With the Drupal ORM

Mathieu Helie

Object-oriented programming offers a powerful abstraction over databases, abstracting their tables into collections of objects with simple, powerful interfaces. This is called an Object-Relational Mapping (or ORM), and is at the heart of modern frameworks such as Rails, Laravel and Symfony.

Drupal’s content model consists of documents of fields instead of single tables, and the basic ORM paradigm needs an extra layer of interfaces to bridge the gap. In Drupal 8 these interfaces are called TypedData and EntityQuery.

In this session we will seek to understand how to work with entity objects in Drupal 8, what the different APIs, plugins, and services do for us, and wrap it up by writing a custom module that generates a complex page layout from a Node entity.

Developers new to Drupal will take away an understanding of what happens behind the scenes when data is accessed and written in entities.
Intermediate developers will understand how to customize the field system to create clean data models that don’t require subentities such as paragraphs or hacky “Helper” objects.
Advanced developers will be introduced to concepts such a serialization and deserialization of entities.

Mathieu Helie
Consulting Developer, Montreal, @mathieuhelie
Drupal developer since 2008, I have worked on a vast diversity of site builds, platform designs, migrations and maintenance disaster recovery for private clients, agencies and enterprise Drupal users. In my free time, I am a backyard complexity theorist and enjoy baking and gardening.

Drupal is a registered trademark of Dries Buytaert.