EntityRepositoryInterface
interface EntityRepositoryInterface (View source)
Provides an interface for an entity repository.
Constants
| CONTEXT_ID_LEGACY_CONTEXT_OPERATION |
|
Methods
Loads an entity by UUID.
Loads an entity by the config target identifier.
Gets the entity translation to be used in the given context.
Retrieves the active entity variant matching the specified context.
Retrieves the active entity variants matching the specified context.
Retrieves the canonical entity variant matching the specified context.
Retrieves the canonical entity variants matching the specified context.
Details
EntityInterface|null
loadEntityByUuid(string $entity_type_id, string $uuid)
Loads an entity by UUID.
Note that some entity types may not support UUIDs.
EntityInterface|null
loadEntityByConfigTarget(string $entity_type_id, string $target)
Loads an entity by the config target identifier.
EntityInterface
getTranslationFromContext(EntityInterface $entity, string $langcode = NULL, array $context = [])
Gets the entity translation to be used in the given context.
This will check whether a translation for the desired language is available and if not, it will fall back to the most appropriate translation based on the provided context.
EntityInterface|null
getActive(string $entity_type_id, int|string $entity_id, array $contexts = NULL)
Retrieves the active entity variant matching the specified context.
If an entity type is revisionable and/or translatable, which entity variant should be handled depends on the context in which the manipulation happens. Based on the specified contextual information, revision and translation negotiation needs to be performed to return the active variant, that is the most up-to-date entity variant in the context scope. This may or may not be an entity variant intended for unprivileged user consumption, in fact it might be a work in progress containing yet to be published information. The active variant should always be retrieved when editing an entity, both in form and in REST workflows, or previewing the related changes.
The negotiation process will not perform any access check, so it is the responsibility of the caller to verify that the user manipulating the entity variant is actually allowed to do so.
EntityInterface[]
getActiveMultiple(string $entity_type_id, array $entity_ids, array $contexts = NULL)
Retrieves the active entity variants matching the specified context.
EntityInterface|null
getCanonical(string $entity_type_id, int|string $entity_id, array $contexts = NULL)
Retrieves the canonical entity variant matching the specified context.
If an entity type is revisionable and/or translatable, which entity variant should be handled depends on the context in which the manipulation happens. This will return the fittest entity variant intended for unprivileged user consumption matching the specified context. This is typically the variant that would be displayed on the entity's canonical route.
The negotiation process will not perform any access check, so it is the responsibility of the caller to verify that the user manipulating the entity variant is actually allowed to do so.
EntityInterface[]
getCanonicalMultiple(string $entity_type_id, array $entity_ids, array $contexts = NULL)
Retrieves the canonical entity variants matching the specified context.