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