function RevisionHtmlRouteProvider::getVersionHistoryRoute

Same name in other branches
  1. 10 core/lib/Drupal/Core/Entity/Routing/RevisionHtmlRouteProvider.php \Drupal\Core\Entity\Routing\RevisionHtmlRouteProvider::getVersionHistoryRoute()

Gets the entity revision history route.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entityType: The entity type.

Return value

\Symfony\Component\Routing\Route|null The entity revision revert route, or NULL if the entity type does not support viewing version history.

1 call to RevisionHtmlRouteProvider::getVersionHistoryRoute()
RevisionHtmlRouteProvider::getRoutes in core/lib/Drupal/Core/Entity/Routing/RevisionHtmlRouteProvider.php
Provides routes for entities.

File

core/lib/Drupal/Core/Entity/Routing/RevisionHtmlRouteProvider.php, line 52

Class

RevisionHtmlRouteProvider
Provides entity revision routes.

Namespace

Drupal\Core\Entity\Routing

Code

protected function getVersionHistoryRoute(EntityTypeInterface $entityType) : ?Route {
    if (!$entityType->hasLinkTemplate('version-history')) {
        return NULL;
    }
    $entityTypeId = $entityType->id();
    return (new Route($entityType->getLinkTemplate('version-history')))
        ->addDefaults([
        '_controller' => VersionHistoryController::class,
        '_title' => 'Revisions',
    ])
        ->setRequirement('_entity_access', $entityTypeId . '.view all revisions')
        ->setOption('entity_type_id', $entityTypeId)
        ->setOption('_admin_route', TRUE)
        ->setOption('parameters', [
        $entityTypeId => [
            'type' => 'entity:' . $entityTypeId,
        ],
    ]);
}

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