Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityLink.php

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal