function RevisionHtmlRouteProvider::getRevisionViewRoute

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

Gets the entity revision view route.

Parameters

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

Return value

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

1 call to RevisionHtmlRouteProvider::getRevisionViewRoute()
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 83

Class

RevisionHtmlRouteProvider
Provides entity revision routes.

Namespace

Drupal\Core\Entity\Routing

Code

protected function getRevisionViewRoute(EntityTypeInterface $entityType) : ?Route {
    if (!$entityType->hasLinkTemplate('revision')) {
        return NULL;
    }
    $entityTypeId = $entityType->id();
    $revisionParameterName = $entityTypeId . '_revision';
    return (new Route($entityType->getLinkTemplate('revision')))
        ->addDefaults([
        '_controller' => EntityRevisionViewController::class,
        '_title_callback' => EntityRevisionViewController::class . '::title',
    ])
        ->setRequirement('_entity_access', $revisionParameterName . '.view revision')
        ->setOption('parameters', [
        $entityTypeId => [
            'type' => 'entity:' . $entityTypeId,
        ],
        $revisionParameterName => [
            'type' => 'entity_revision:' . $entityTypeId,
        ],
    ]);
}

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