public function FallbackController::getTranslation in Entity Language Fallback 8
Parameters
string $lang_code: Language code
\Drupal\Core\Entity\ContentEntityInterface $entity: Entity
Return value
mixed Fallback entity translation, or FALSE if nothing was found.
Overrides FallbackControllerInterface::getTranslation
1 call to FallbackController::getTranslation()
File
- src/
FallbackController.php, line 84  
Class
Namespace
Drupal\entity_language_fallbackCode
public function getTranslation($lang_code, ContentEntityInterface $entity) {
  $this
    ->ensureFallbackChain($lang_code);
  foreach ($this->fallback_chain[$lang_code] as $candidate) {
    if ($entity
      ->hasTranslation($candidate)) {
      return $entity
        ->getTranslation($candidate);
    }
  }
  return FALSE;
}