DefaultLanguageRenderer.php

Same filename in other branches
  1. 9 core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php
  2. 8.9.x core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php
  3. 10 core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php

Namespace

Drupal\views\Entity\Render

File

core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php

View source
<?php

namespace Drupal\views\Entity\Render;

use Drupal\views\ResultRow;

/**
 * Renders entities in their default language.
 */
class DefaultLanguageRenderer extends EntityTranslationRendererBase {
    
    /**
     * {@inheritdoc}
     */
    public function getLangcode(ResultRow $row) {
        return $row->_entity
            ->getUntranslated()
            ->language()
            ->getId();
    }
    
    /**
     * {@inheritdoc}
     */
    public function getLangcodeByRelationship(ResultRow $row, string $relationship = 'none') : string {
        $entity = $this->getEntity($row, $relationship);
        return $entity->getUntranslated()
            ->language()
            ->getId();
    }

}

Classes

Title Deprecated Summary
DefaultLanguageRenderer Renders entities in their default language.

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