function EntityTranslationRendererBase::preRender

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

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));
    }
}

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