3 namespace Drupal\Core\Entity;
6 * Provides an interface for an entity repository.
8 interface EntityRepositoryInterface {
11 * Loads an entity by UUID.
13 * Note that some entity types may not support UUIDs.
15 * @param string $entity_type_id
16 * The entity type ID to load from.
18 * The UUID of the entity to load.
20 * @return \Drupal\Core\Entity\EntityInterface|null
21 * The entity object, or NULL if there is no entity with the given UUID.
23 * @throws \Drupal\Core\Entity\EntityStorageException
24 * Thrown in case the requested entity type does not support UUIDs.
26 public function loadEntityByUuid($entity_type_id, $uuid);
29 * Loads an entity by the config target identifier.
31 * @param string $entity_type_id
32 * The entity type ID to load from.
33 * @param string $target
34 * The configuration target to load, as returned from
35 * \Drupal\Core\Entity\EntityInterface::getConfigTarget().
37 * @return \Drupal\Core\Entity\EntityInterface|null
38 * The entity object, or NULL if there is no entity with the given config
41 * @throws \Drupal\Core\Entity\EntityStorageException
42 * Thrown if the target identifier is a UUID but the entity type does not
45 * @see \Drupal\Core\Entity\EntityInterface::getConfigTarget()
47 public function loadEntityByConfigTarget($entity_type_id, $target);
50 * Gets the entity translation to be used in the given context.
52 * This will check whether a translation for the desired language is available
53 * and if not, it will fall back to the most appropriate translation based on
54 * the provided context.
56 * @param \Drupal\Core\Entity\EntityInterface $entity
57 * The entity whose translation will be returned.
58 * @param string $langcode
59 * (optional) The language of the current context. Defaults to the current
61 * @param array $context
62 * (optional) An associative array of arbitrary data that can be useful to
63 * determine the proper fallback sequence.
65 * @return \Drupal\Core\Entity\EntityInterface
66 * An entity object for the translated data.
68 * @see \Drupal\Core\Language\LanguageManagerInterface::getFallbackCandidates()
70 public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []);