Introduce the EntityTypeAwareInterface interface for entity operations uniformisation

Created on 28 September 2012, about 12 years ago
Updated 17 August 2023, over 1 year ago

I'd like to introduce the EntityTypeAwareInterface that brings two methods: getEntityType() and getEntityInfo().

The goal of this is having a natural object oriented API which allows, whenever we are working with any entity controller or entity object to fetch the entity type and info easily.

One use case where it could be useful is there: #1781372: Add an API for listing (configuration) entities . Having this would avoid "entity type" and "entity storage" parameters duplication, because the storage is supposed to know on which entity type it works.

I wrote a simple patch, that make all of EntityStorageControllerInterface, EntityInterface and EntityFormControllerInterface implementing this new EntityTypeAwareInterface interface.

Also wrote an abstract base class, and used it in every of the default implementations. I manually tested and right now it works gracefully when working with nodes, comments and taxonomy tags.

Ideally, this goes into the direction of injecting the entity info (eventually materializing it as an object/interface too) instead of letting all those objects doing direct global state procedural calls. The idea behind this is in the mid-term getting rid of the procedural API calls in the object oriented code.

Feature request
Status

Needs work

Version

9.5

Component
Entity 

Last updated 2 days ago

Created by

🇫🇷France pounard

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