Entities 202 - Rapid prototyping for custom entities

rlnorthcutt

One of the great strengths of Drupal is the ability to quickly create new content types to store and use data. While this is a very common approach, there are limitations to using nodes to store all of your data. Often, there are advantages to creating custom entities to store, display, and handle our data.

Using Drupal console, we can quickly create boilerplate code for a custom entity, but this is just the beginning. We also need to define the fields for the database, entity configuration, custom methods, and how our module will interact with others. This sounds like a big task, but with a good understanding of the Entity API, its possible to get a lot of work done very quickly.

It is often easier, faster, and more performant to create your own custom entities for non-content data.

In this session we will be starting from scratch and building a custom module for our entity from the ground up. We will discuss:

  • Performance considerations
  • Creating more complex custom entities
  • Creating and exporting configuration
  • Basic hook implementation
  • Providing events for other modules to subscribe to
  • Basic test coverage
  • Which core entities to extend
  • Problems to avoid

 

This session is an extension of the "Entities 201" session from two years ago, and the fourth in the series. It would be good to review Entities 201 prior to attending, but this is not required. We are diving deeper into the Entity API and learning more about building custom modules in general. This session is intended to encourage you to be bolder about writing your own code.

Drupal 8 makes it easier for you to be a "real" developer - writing concise, performant, and secure code with relative ease.

The scaffolding along with the great comments makes this a very friendly process, but this is a technical discussion about code. Attendees will be able to immediately apply what we are learning as we progress if they have a local development environment and Drupal console installed. Please note that it is not intended to be a "follow along" session - we will be moving very quickly. However, the slides, instructions, and code will be provided at the end.

Previous sessions in the series:

Program tags

back end development, data, php

Experience Level

Intermediate

Drupal Version