RevisionLink.php in Zircon Profile 8
File
core/modules/node/src/Plugin/views/field/RevisionLink.php
View source
<?php
namespace Drupal\node\Plugin\views\field;
use Drupal\Core\Url;
use Drupal\views\Plugin\views\field\LinkBase;
use Drupal\views\ResultRow;
class RevisionLink extends LinkBase {
protected function getUrlInfo(ResultRow $row) {
$node = $this
->getEntity($row);
return !$node
->isDefaultRevision() ? Url::fromRoute('entity.node.revision', [
'node' => $node
->id(),
'node_revision' => $node
->getRevisionId(),
]) : $node
->urlInfo();
}
protected function renderLink(ResultRow $row) {
$node = $this
->getEntity($row);
if (!$node
->getRevisionid()) {
return '';
}
$text = parent::renderLink($row);
$this->options['alter']['query'] = $this
->getDestinationArray();
return $text;
}
protected function getDefaultLabel() {
return $this
->t('View');
}
}
Classes
Name |
Description |
RevisionLink |
Field handler to present a link to a node revision. |