function VersionHistoryController::buildRevertRevisionLink

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Entity/Controller/VersionHistoryController.php \Drupal\Core\Entity\Controller\VersionHistoryController::buildRevertRevisionLink()

Builds a link to revert an entity revision.

Parameters

\Drupal\Core\Entity\RevisionableInterface $revision: The entity to build a revert revision link for.

Return value

array|null A link to revert an entity revision, or NULL if the entity type does not have an a route to revert an entity revision.

1 call to VersionHistoryController::buildRevertRevisionLink()
VersionHistoryController::getOperationLinks in core/lib/Drupal/Core/Entity/Controller/VersionHistoryController.php
Get operations for an entity revision.

File

core/lib/Drupal/Core/Entity/Controller/VersionHistoryController.php, line 89

Class

VersionHistoryController
Provides a controller showing revision history for an entity.

Namespace

Drupal\Core\Entity\Controller

Code

protected function buildRevertRevisionLink(RevisionableInterface $revision) : ?array {
    if (!$revision->hasLinkTemplate('revision-revert-form')) {
        return NULL;
    }
    $url = $revision->toUrl('revision-revert-form');
    // @todo Merge in cacheability after
    // https://www.drupal.org/project/drupal/issues/2473873.
    if (!$url->access()) {
        return NULL;
    }
    return [
        'title' => $this->t('Revert'),
        'url' => $url,
    ];
}

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