Providing a custom storage handler
Storage handlers control the loading, saving, and deleting of an entity. \Drupal\Core\Entity\ContentEntityType
provides the base entity type definition for all content entity types. If it is not specified, then the default storage handler is \Drupal\Core\Entity\Sql\SqlContentEntityStorage
. This class can be extended to implement alternative load
methods or adjustments on save.
In this recipe, we will implement a method that supports loading an entity by a specific property instead of having to write a specific loadByProperties
method call.
Getting ready
You will need a custom module to place the code into in order to implement a configuration entity type. Create an src
directory for your PSR-4 style classes. A custom ...
Get Drupal 8: Enterprise Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.