function EntityTranslationRendererBase::preRenderByRelationship

Same name in other branches
  1. 10 core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php \Drupal\views\Entity\Render\EntityTranslationRendererBase::preRenderByRelationship()

Runs before each entity is rendered if a relationship is needed.

Parameters

\Drupal\views\ResultRow[] $result: The full array of results from the query.

string $relationship: The relationship to be used.

1 call to EntityTranslationRendererBase::preRenderByRelationship()
EntityTranslationRendererBase::preRender in core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php
Runs before each entity is rendered.
1 method overrides EntityTranslationRendererBase::preRenderByRelationship()
TranslationLanguageRenderer::preRenderByRelationship in core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php
Runs before each entity is rendered if a relationship is needed.

File

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

Class

EntityTranslationRendererBase
Defines a base class for entity translation renderers.

Namespace

Drupal\views\Entity\Render

Code

public function preRenderByRelationship(array $result, string $relationship) : void {
    $view_builder = \Drupal::entityTypeManager()->getViewBuilder($this->entityType
        ->id());
    foreach ($result as $row) {
        if ($entity = $this->getEntity($row, $relationship)) {
            $entity->view = $this->view;
            $this->build[$entity->id()] = $view_builder->view($entity, $this->view->rowPlugin->options['view_mode'], $this->getLangcodeByRelationship($row, $relationship));
        }
    }
}

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