function TranslationLanguageRenderer::getLangcodeTable

Same name in other branches
  1. 9 core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php \Drupal\views\Entity\Render\TranslationLanguageRenderer::getLangcodeTable()
  2. 8.9.x core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php \Drupal\views\Entity\Render\TranslationLanguageRenderer::getLangcodeTable()
  3. 10 core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php \Drupal\views\Entity\Render\TranslationLanguageRenderer::getLangcodeTable()

Returns the name of the table holding the "langcode" field.

Parameters

\Drupal\views\Plugin\views\query\QueryPluginBase $query: The query being executed.

string $relationship: The relationship used by the entity type.

Return value

string A table name.

1 call to TranslationLanguageRenderer::getLangcodeTable()
TranslationLanguageRenderer::query in core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php

File

core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php, line 51

Class

TranslationLanguageRenderer
Renders entity translations in their row language.

Namespace

Drupal\views\Entity\Render

Code

protected function getLangcodeTable(QueryPluginBase $query, $relationship) {
    
    /** @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage $storage */
    $storage = \Drupal::entityTypeManager()->getStorage($this->entityType
        ->id());
    $langcode_key = $this->entityType
        ->getKey('langcode');
    $langcode_table = $storage->getTableMapping()
        ->getFieldTableName($langcode_key);
    // If the entity type is revisionable, we need to take into account views of
    // entity revisions. Usually the view will use the entity data table as the
    // query base table, however, in case of an entity revision view, we need to
    // use the revision table or the revision data table, depending on which one
    // is being used as query base table.
    if ($this->entityType
        ->isRevisionable()) {
        $query_base_table = $query->relationships[$relationship]['base'] ?? $this->view->storage
            ->get('base_table');
        $revision_table = $storage->getRevisionTable();
        $revision_data_table = $storage->getRevisionDataTable();
        if ($query_base_table === $revision_table) {
            $langcode_table = $revision_table;
        }
        elseif ($query_base_table === $revision_data_table) {
            $langcode_table = $revision_data_table;
        }
    }
    return $langcode_table;
}

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