function EntityLink::preRender

Same name in other branches
  1. 9 core/modules/comment/src/Plugin/views/field/EntityLink.php \Drupal\comment\Plugin\views\field\EntityLink::preRender()
  2. 8.9.x core/modules/comment/src/Plugin/views/field/EntityLink.php \Drupal\comment\Plugin\views\field\EntityLink::preRender()
  3. 10 core/modules/comment/src/Plugin/views/field/EntityLink.php \Drupal\comment\Plugin\views\field\EntityLink::preRender()

Overrides FieldPluginBase::preRender

File

core/modules/comment/src/Plugin/views/field/EntityLink.php, line 56

Class

EntityLink
Handler for showing comment module's entity links.

Namespace

Drupal\comment\Plugin\views\field

Code

public function preRender(&$values) {
    // Render all nodes, so you can grep the comment links.
    $entities = [];
    foreach ($values as $row) {
        $entity = $row->_entity;
        $entities[$entity->id()] = $entity;
    }
    if ($entities) {
        $entityTypeId = reset($entities)->getEntityTypeId();
        $viewMode = $this->options['teaser'] ? 'teaser' : 'full';
        $this->build = \Drupal::entityTypeManager()->getViewBuilder($entityTypeId)
            ->viewMultiple($entities, $viewMode);
    }
}

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