Make EntityTypeManager provide an entity factory

Created on 15 December 2012, almost 12 years ago
Updated 14 February 2023, almost 2 years ago

Problem/Motivation

EntityStorageInterface::create() creates a full working entity object, filled up with default values.
This is fine most of the time, but there are usecases where you simply don't need these default values.

One example is: REST module wants to represents a diff entity, so it doesn't need to load default values.

By providing EntityManager::createInstance() we would not only provide such a lightweight function, but it would also
allow to have a valid implementation of the PluginManagerInterface

Proposed resolution

Remaining tasks

User interface changes

API changes

EntityManager is a plugin manager, which means its interface includes createInstance() and getInstance(). These are currently non-functional, because #1763974: Convert entity type info into plugins β†’ only addressed discovery, not the rest of plugin manager functionality.

Making them functional will allow classes that need to create and load entities to do so via an injected manager rather than by calling global functions. This is another step towards making things unit testable and better managed via the dependency injection container.

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
EntityΒ  β†’

Last updated 2 minutes ago

Created by

πŸ‡ΊπŸ‡ΈUnited States effulgentsia

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

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