Provide a method of DI for entities

Created on 23 November 2013, about 11 years ago
Updated 4 October 2022, about 2 years ago

We should provide a method of DI for entities in order to avoid \Drupal calls in classes. This is especially pertinent now that we have bundle classes in core, where the only alternative to entity-specific services is \Drupal calls on the bundle class.

Original:

Entities have never been injected with services, because it would not have kept them serializable, a feature required by the REST module. However, if we make all entities extend \Drupal\Core\DependencyInjection\DependencySerialization that was introduced by #2004282: Injected dependencies and serialization hell β†’ , services will no longer be a problem for serialization as only their IDs will be serialized.
Doing this will let us write cleaner production code, as we no longer need the wrappers that #2134857: PHPUnit test the entity base classes β†’ introduces for testing, and our tests will no longer have to mock those wrapper methods.

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
EntityΒ  β†’

Last updated about 17 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom Xano Southampton

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