You are here

public function RouteSubscriber::alterRoutes in Paranoia 8

Alters existing routes for a specific collection.

Parameters

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

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 16

Class

RouteSubscriber
Listens to dynamic route events.

Namespace

Drupal\paranoia\Routing

Code

public function alterRoutes(RouteCollection $collection) {
  $hidden_routes = \Drupal::moduleHandler()
    ->invokeAll('paranoia_hide_routes');
  foreach ($hidden_routes as $key) {
    if ($route = $collection
      ->get($key)) {
      $route
        ->setRequirement('_access', 'FALSE');
    }
  }
}