Despite great advances to make more and more functionality generic and available to all entity types, most Drupal sites still use the entity types provided by core, most prominently nodes. For many sites that's a great fit! But there's also a lot of sites where the constraints of the "everything is a node" mantra really show their rough edges and which could benefit from a more custom-tailored approach to the data model. In this session we will endeavor to break free from those constraints by creating a custom entity type via code. In doing so we will encounter all of the things that the Entity API provides generically for you and what the benefits of this code-driven approach are. The spoiler is that you can actually get pretty much everything you want out of a custom entity type with very little code. In fact, this will be a live-coding session and at the end we will have a fully-fledged entity type with all the bells and whistles you would expect.
This is an updated version of similar sessions/trainings by me (and friends) done in:
- Dev Days Szeged 2014
- NYCCamp 2014
- DrupalCon New Orleans 2016
- DrupalCon Dublin 2016
- DrupalCamp Essen 2024
See also the (somewhat outdated, but still useful) Entity Type Walkthrough that we created for the aforementioned DrupalCon trainings.
In contrast to the previous sessions, this will one will focus less on the concepts of the Entity API and more on real-world use-cases, in particular by using the contrib Entity API module from the start.