function TranslationLanguageRenderer::query
Same name in other branches
- 9 core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php \Drupal\views\Entity\Render\TranslationLanguageRenderer::query()
- 8.9.x core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php \Drupal\views\Entity\Render\TranslationLanguageRenderer::query()
- 11.x core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php \Drupal\views\Entity\Render\TranslationLanguageRenderer::query()
Overrides EntityTranslationRendererBase::query
File
-
core/
modules/ views/ src/ Entity/ Render/ TranslationLanguageRenderer.php, line 24
Class
- TranslationLanguageRenderer
- Renders entity translations in their row language.
Namespace
Drupal\views\Entity\RenderCode
public function query(QueryPluginBase $query, $relationship = NULL) {
// In order to render in the translation language of the entity, we need
// to add the language code of the entity to the query. Skip if the site
// is not multilingual or the entity is not translatable.
if (!$this->languageManager
->isMultilingual() || !$this->entityType
->hasKey('langcode')) {
return;
}
$langcode_table = $this->getLangcodeTable($query, $relationship);
if ($langcode_table) {
/** @var \Drupal\views\Plugin\views\query\Sql $query */
$table_alias = $query->ensureTable($langcode_table, $relationship);
$langcode_key = $this->entityType
->getKey('langcode');
$this->langcodeAlias = $query->addField($table_alias, $langcode_key);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.