You are here

public function TranslationLanguageRenderer::preRender in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php \Drupal\views\Entity\Render\TranslationLanguageRenderer::preRender()

Runs before each entity is rendered.

Parameters

$result: The full array of results from the query.

Overrides EntityTranslationRendererBase::preRender

File

core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php, line 48
Contains \Drupal\views\Entity\Render\TranslationLanguageRenderer.

Class

TranslationLanguageRenderer
Renders entity translations in their row language.

Namespace

Drupal\views\Entity\Render

Code

public function preRender(array $result) {
  $view_builder = $this->view->rowPlugin->entityManager
    ->getViewBuilder($this->entityType
    ->id());

  /** @var \Drupal\views\ResultRow $row */
  foreach ($result as $row) {
    $entity = $row->_entity;
    $entity->view = $this->view;
    $langcode = $this
      ->getLangcode($row);
    $this->build[$entity
      ->id()][$langcode] = $view_builder
      ->view($entity, $this->view->rowPlugin->options['view_mode'], $this
      ->getLangcode($row));
  }
}