Drupal 8  8.0.2
EntityRepository Class Reference
Inheritance diagram for EntityRepository:

Public Member Functions

 __construct (EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager)
 
 loadEntityByUuid ($entity_type_id, $uuid)
 
 loadEntityByConfigTarget ($entity_type_id, $target)
 
 getTranslationFromContext (EntityInterface $entity, $langcode=NULL, $context=array())
 

Protected Attributes

 $entityTypeManager
 
 $languageManager
 

Detailed Description

Provides several mechanisms for retrieving entities.

Constructor & Destructor Documentation

__construct ( EntityTypeManagerInterface  $entity_type_manager,
LanguageManagerInterface  $language_manager 
)

Constructs a new EntityRepository.

Parameters
\Drupal\Core\Entity\EntityTypeManagerInterface$entity_type_managerThe entity type manager.
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.

References Drupal\entityTypeManager(), and Drupal\languageManager().

Here is the call graph for this function:

Member Function Documentation

getTranslationFromContext ( EntityInterface  $entity,
  $langcode = NULL,
  $context = array() 
)

{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.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity whose translation will be returned.
string$langcode(optional) The language of the current context. Defaults to the current content language.
array$context(optional) An associative array of arbitrary data that can be useful to determine the proper fallback sequence.
Returns
An entity object for the translated data.
See Also
::getFallbackCandidates()
}

Implements EntityRepositoryInterface.

References RefinableCacheableDependencyInterface\addCacheContexts(), LanguageInterface\LANGCODE_DEFAULT, EntityInterface\language(), Drupal\languageManager(), and LanguageInterface\TYPE_CONTENT.

Here is the call graph for this function:

loadEntityByConfigTarget (   $entity_type_id,
  $target 
)

{Loads an entity by the config target identifier.

Parameters
string$entity_type_idThe entity type ID to load from.
string$targetThe configuration target to load, as returned from ::getConfigTarget().
Returns
|null The entity object, or NULL if there is no entity with the given config target identifier.
Exceptions
\Drupal\Core\Entity\EntityStorageExceptionThrown if the target identifier is a UUID but the entity type does not support UUIDs.
See Also
::getConfigTarget()
}

Implements EntityRepositoryInterface.

References Drupal\entityTypeManager(), and EntityRepository\loadEntityByUuid().

Here is the call graph for this function:

loadEntityByUuid (   $entity_type_id,
  $uuid 
)

{Loads an entity by UUID.Note that some entity types may not support UUIDs.

Parameters
string$entity_type_idThe entity type ID to load from.
string$uuidThe UUID of the entity to load.
Returns
|null The entity object, or NULL if there is no entity with the given UUID.
Exceptions
\Drupal\Core\Entity\EntityStorageExceptionThrown in case the requested entity type does not support UUIDs.
}

Implements EntityRepositoryInterface.

References Drupal\entityTypeManager().

Referenced by EntityRepository\loadEntityByConfigTarget().

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: