You are here

protected function GroupRevisionRouteSubscriber::alterRoutes in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Routing/GroupRevisionRouteSubscriber.php \Drupal\group\Entity\Routing\GroupRevisionRouteSubscriber::alterRoutes()

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Entity/Routing/GroupRevisionRouteSubscriber.php, line 16

Class

GroupRevisionRouteSubscriber
Swaps out the revision UI access callbacks.

Namespace

Drupal\group\Entity\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  if ($route = $collection
    ->get('entity.group.revision')) {
    $requirements = $route
      ->getRequirements();
    unset($requirements['_entity_access_revision']);
    $requirements['_group_revision'] = 'view';
    $route
      ->setRequirements($requirements);
    $route
      ->setOption('_group_operation_route', TRUE);
  }
  if ($route = $collection
    ->get('entity.group.revision_revert_form')) {
    $requirements = $route
      ->getRequirements();
    unset($requirements['_entity_access_revision']);
    $requirements['_group_revision'] = 'update';
    $route
      ->setRequirements($requirements);
    $route
      ->setDefault('_form', '\\Drupal\\group\\Entity\\Form\\GroupRevisionRevertForm');
    $route
      ->setOption('_group_operation_route', TRUE);
  }
  if ($route = $collection
    ->get('entity.group.version_history')) {
    $requirements = $route
      ->getRequirements();
    unset($requirements['_entity_access_revision']);
    $requirements['_group_revision'] = 'list';
    $route
      ->setRequirements($requirements);
    $route
      ->setDefault('_controller', '\\Drupal\\group\\Entity\\Controller\\GroupRevisionOverviewController::revisionOverviewController');
    $route
      ->setOption('_group_operation_route', TRUE);
  }
}