EntityRepositoryInterface::getTranslationFromContext

public EntityRepositoryInterface::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 $entity: The 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.

Return value

\Drupal\Core\Entity\EntityInterface An entity object for the translated data.

See also

\Drupal\Core\Language\LanguageManagerInterface::getFallbackCandidates()

File

core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php, line 70

Class

EntityRepositoryInterface
Provides an interface for an entity repository.

Namespace

Drupal\Core\Entity

Code

public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = array());
doc_Drupal
2016-10-29 09:07:26
Comments
Leave a Comment

Please login to continue.