You are here

protected function DiffRouteProvider::getDiffRoute in Diff 8

Constructs the diff route.

Parameters

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

Return value

\Symfony\Component\Routing\Route|null The diff route.

1 call to DiffRouteProvider::getDiffRoute()
DiffRouteProvider::getRoutes in src/Routing/DiffRouteProvider.php
Provides routes for entities.

File

src/Routing/DiffRouteProvider.php, line 35

Class

DiffRouteProvider
Contains routes for diff functionality.

Namespace

Drupal\diff\Routing

Code

protected function getDiffRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('revisions-diff')) {
    $route = new Route($entity_type
      ->getLinkTemplate('revisions-diff'));
    $route
      ->addDefaults([
      '_controller' => '\\Drupal\\diff\\Controller\\PluginRevisionController::compareEntityRevisions',
      'filter' => 'split_fields',
    ]);
    $route
      ->addRequirements([
      '_entity_access' => $entity_type
        ->id() . '.view',
    ]);
    $route
      ->setOption('parameters', [
      $entity_type
        ->id() => [
        'type' => 'entity:' . $entity_type
          ->id(),
      ],
      'left_revision' => [
        'type' => 'entity_revision:' . $entity_type
          ->id(),
      ],
      'right_revision' => [
        'type' => 'entity_revision:' . $entity_type
          ->id(),
      ],
    ]);
    return $route;
  }
}