Skip to main content

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

topic-dev
Backend & Dev-ops
Speaker(s)
Mathieu Helie
Audience Experience Level
Everyone

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.