Quantcast
Viewing all articles
Browse latest Browse all 294883

Deprecate static entity methods (create, load, loadMultiple) and rethink EntityRepository::getEntityTypeFromClass

Problem/Motivation

Static methods for creating and loading entities go against the concept of dependency injection. Furthermore, they created the need for being able to resolve an entity type from a class name, something which leads to issues when trying to introduce custom entity classes based on given scenarios. (E.g. one class to serve multiple bundles)

Proposed resolution

Mark ::create(), ::load() and ::loadMultiple() as deprecated and remove their usage from core.

Remaining tasks

EntityRepository::getEntityTypeFromClass is only being used by these static methods and the EntityNormalizer. If we can change that last class to also be smarter about how it finds the entity type ID to use, then we can get rid of getEntityTypeFromClass() altogether. If this discussion takes up too much space we can create a related issue for it.

User interface changes

None

API changes

None, you can already use the entity storage for the same functionality.

Data model changes

None

Release notes snippet

TBD

Bonus benefit: This would instantly fix #3252421: EntityInterface::loadMultiple and EntityInterface::load, if invoked on a bundle class, should only return entities of that bundle


Viewing all articles
Browse latest Browse all 294883

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>