function WorkspacesEntityRepository::getTranslationFromContext

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. See \Drupal\Core\Language\LanguageManagerInterface::getFallbackCandidates().

Return value

\Drupal\Core\Entity\EntityInterface|null An entity object for the translated data, or NULL if the requested translation is missing, forbidden, or unavailable.

Overrides EntityRepositoryInterface::getTranslationFromContext

File

core/modules/workspaces/src/WorkspacesEntityRepository.php, line 35

Class

WorkspacesEntityRepository
Provides workspace-specific mechanisms for retrieving entities.

Namespace

Drupal\workspaces

Code

public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []) {
  return $this->inner
    ->getTranslationFromContext($entity, $langcode, $context);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.