3 namespace Drupal\node\Plugin\views\field;
6 use Drupal\views\Plugin\views\field\LinkBase;
7 use Drupal\views\ResultRow;
10 * Field handler to present a link to a node revision.
12 * @ingroup views_field_handlers
14 * @ViewsField("node_revision_link")
16 class RevisionLink extends LinkBase {
21 protected function getUrlInfo(ResultRow $row) {
22 /** @var \Drupal\node\NodeInterface $node */
23 $node = $this->getEntity($row);
24 // Current revision uses the node view path.
25 return !$node->isDefaultRevision() ?
26 Url::fromRoute('entity.node.revision', ['node' => $node->id(), 'node_revision' => $node->getRevisionId()]) :
33 protected function renderLink(ResultRow $row) {
34 /** @var \Drupal\node\NodeInterface $node */
35 $node = $this->getEntity($row);
36 if (!$node->getRevisionid()) {
39 $text = parent::renderLink($row);
40 $this->options['alter']['query'] = $this->getDestinationArray();
47 protected function getDefaultLabel() {
48 return $this->t('View');