function RevisionLinkRevert::render_link

Overrides RevisionLink::render_link

File

drupal/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkRevert.php, line 29
Definition of Drupal\node\Plugin\views\field\RevisionLinkRevert.

Class

RevisionLinkRevert
Field handler to present a link to revert a node to a revision.

Namespace

Drupal\node\Plugin\views\field

Code

function render_link($data, $values) {
  list($node, $vid) = $this
    ->get_revision_entity($values, 'update');
  if (!isset($vid)) {
    return;
  }

  // Current revision cannot be reverted.
  if ($node->vid == $vid) {
    return;
  }
  $this->options['alter']['make_link'] = TRUE;
  $this->options['alter']['path'] = 'node/' . $node->nid . "/revisions/{$vid}/revert";
  $this->options['alter']['query'] = drupal_get_destination();
  return !empty($this->options['text']) ? $this->options['text'] : t('revert');
}