function VersionHistoryController::buildDeleteRevisionLink

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Entity/Controller/VersionHistoryController.php \Drupal\Core\Entity\Controller\VersionHistoryController::buildDeleteRevisionLink()

Builds a link to delete an entity revision.

Parameters

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

Return value

array|null A link render array.

1 call to VersionHistoryController::buildDeleteRevisionLink()
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 116

Class

VersionHistoryController
Provides a controller showing revision history for an entity.

Namespace

Drupal\Core\Entity\Controller

Code

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

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