Refactor the entity system to be evented

Created on 29 April 2013, over 11 years ago
Updated 18 October 2024, 2 months ago

Problem/Motivation

It was decided that Drupal 8 will rely heavily on OOP. While the entity system does this, the only way to interact with is via procedural code. This patch intends to remove the necessity to write procedural code and opens up the possibility to make (much more) of the entity code unit testable. Other problems include a total mixup of storage independent logic with the actual storage, for example calculating the comment thread vs storing the comment thread. There are no interfaces for the storage controllers because it is entirely unclear what the specific storage needs are. The number of hooks available were totally unwieldy as well (quick, does hook_field_load fire before or after hook_field_attach_load? What about hook_field_insert and hook_field_attach_insert? Where does hook_entity_load enter into the picture?).

Proposed resolution

Hooks are out. Events are in. Storage controllers thin down and get an interface. The logic moves into a StorageSubscriber. Entity hook implementations move into an EntitySubscriber.

Remaining tasks

The patch is not yet green. It is being worked on in http://drupal.org/sandbox/chx/1857558 entitystorage branch.

User interface changes

No user interface changes.

API changes

All entity hooks die -- from hook_entity_load to hook_user_delete, all. Field attach storage hooks die. Field storage callbacks die. Entity events are born.

Related Issues

#1497374: Switch from Field-based storage to Entity-based storage
#1893772: Move entity-type specific storage logic into entity classes

📌 Task
Status

Closed: duplicate

Version

11.0 🔥

Component

entity system

Created by

🇨🇦Canada chx

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024