RevisionLinkRevert.php

Same filename in other branches
  1. 9 core/modules/node/src/Plugin/views/field/RevisionLinkRevert.php
  2. 8.9.x core/modules/node/src/Plugin/views/field/RevisionLinkRevert.php
  3. 10 core/modules/node/src/Plugin/views/field/RevisionLinkRevert.php

Namespace

Drupal\node\Plugin\views\field

File

core/modules/node/src/Plugin/views/field/RevisionLinkRevert.php

View source
<?php

namespace Drupal\node\Plugin\views\field;

use Drupal\Core\Url;
use Drupal\views\Attribute\ViewsField;
use Drupal\views\ResultRow;

/**
 * Field handler to present a link to revert a node to a revision.
 *
 * @ingroup views_field_handlers
 */
class RevisionLinkRevert extends RevisionLink {
    
    /**
     * {@inheritdoc}
     */
    protected function getUrlInfo(ResultRow $row) {
        
        /** @var \Drupal\node\NodeInterface $node */
        $node = $this->getEntity($row);
        if (!$node) {
            return NULL;
        }
        return Url::fromRoute('node.revision_revert_confirm', [
            'node' => $node->id(),
            'node_revision' => $node->getRevisionId(),
        ]);
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getDefaultLabel() {
        return $this->t('Revert');
    }

}

Classes

Title Deprecated Summary
RevisionLinkRevert Field handler to present a link to revert a node to a revision.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.