You are here

public function RouteSubscriber::alterRoutes in Taxonomy access fix 8

New and improved hook_menu_alter().

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 13

Class

RouteSubscriber

Namespace

Drupal\taxonomy_access_fix\Routing

Code

public function alterRoutes(RouteCollection $collection) {

  // admin/structure/taxonomy
  if ($route = $collection
    ->get('entity.taxonomy_vocabulary.collection')) {
    $route
      ->setRequirements([
      '_custom_access' => '\\taxonomy_access_fix_route_access',
    ]);
    $route
      ->setOption('op', 'index');
  }

  // admin/structure/taxonomy/%vocabulary
  if ($route = $collection
    ->get('entity.taxonomy_vocabulary.overview_form')) {
    $route
      ->setRequirements([
      '_custom_access' => '\\taxonomy_access_fix_route_access',
    ]);
    $route
      ->setOption('op', 'list terms');
  }

  // admin/structure/taxonomy/%vocabulary/add
  if ($route = $collection
    ->get('entity.taxonomy_term.add_form')) {
    $route
      ->setRequirements([
      '_custom_access' => '\\taxonomy_access_fix_route_access',
    ]);
    $route
      ->setOption('op', 'add terms');
  }

  // admin/structure/taxonomy/manage/%vocabulary/reset
  if ($route = $collection
    ->get('entity.taxonomy_vocabulary.reset_form')) {
    $route
      ->setRequirements([
      '_custom_access' => '\\taxonomy_access_fix_route_access',
    ]);
    $route
      ->setOption('op', 'reorder terms');
  }
}