You are here

public function EntityTranslationRendererBase::preRender in Drupal 8

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

Runs before each entity is rendered.

Parameters

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

Overrides RendererBase::preRender

1 method overrides EntityTranslationRendererBase::preRender()
TranslationLanguageRenderer::preRender in core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php
Runs before each entity is rendered.

File

core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php, line 33

Class

EntityTranslationRendererBase
Defines a base class for entity translation renderers.

Namespace

Drupal\views\Entity\Render

Code

public function preRender(array $result) {
  $view_builder = \Drupal::entityTypeManager()
    ->getViewBuilder($this->entityType
    ->id());

  /** @var \Drupal\views\ResultRow $row */
  foreach ($result as $row) {

    // @todo Take relationships into account.
    //   See https://www.drupal.org/node/2457999.
    $entity = $row->_entity;
    $entity->view = $this->view;
    $this->build[$entity
      ->id()] = $view_builder
      ->view($entity, $this->view->rowPlugin->options['view_mode'], $this
      ->getLangcode($row));
  }
}