function EntityTranslationRenderTrait::getEntityTranslationRenderer
Same name in other branches
- 8.9.x core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php \Drupal\views\Entity\Render\EntityTranslationRenderTrait::getEntityTranslationRenderer()
- 10 core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php \Drupal\views\Entity\Render\EntityTranslationRenderTrait::getEntityTranslationRenderer()
- 11.x core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php \Drupal\views\Entity\Render\EntityTranslationRenderTrait::getEntityTranslationRenderer()
Returns the current renderer.
Return value
\Drupal\views\Entity\Render\EntityTranslationRendererBase The configured renderer.
File
-
core/
modules/ views/ src/ Entity/ Render/ EntityTranslationRenderTrait.php, line 28
Class
- EntityTranslationRenderTrait
- Trait used to instantiate the view's entity translation renderer.
Namespace
Drupal\views\Entity\RenderCode
protected function getEntityTranslationRenderer() {
if (!isset($this->entityTranslationRenderer)) {
$view = $this->getView();
$rendering_language = $view->display_handler
->getOption('rendering_language');
$langcode = NULL;
$dynamic_renderers = [
'***LANGUAGE_entity_translation***' => 'TranslationLanguageRenderer',
'***LANGUAGE_entity_default***' => 'DefaultLanguageRenderer',
];
if (isset($dynamic_renderers[$rendering_language])) {
// Dynamic language set based on result rows or instance defaults.
$renderer = $dynamic_renderers[$rendering_language];
}
else {
if (strpos($rendering_language, '***LANGUAGE_') !== FALSE) {
$langcode = PluginBase::queryLanguageSubstitutions()[$rendering_language];
}
else {
// Specific langcode set.
$langcode = $rendering_language;
}
$renderer = 'ConfigurableLanguageRenderer';
}
$class = '\\Drupal\\views\\Entity\\Render\\' . $renderer;
$entity_type = $this->getEntityTypeManager()
->getDefinition($this->getEntityTypeId());
$this->entityTranslationRenderer = new $class($view, $this->getLanguageManager(), $entity_type, $langcode);
}
return $this->entityTranslationRenderer;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.