public function RouteSubscriber::alterRoutes in Administer Users by Role 8.2
Same name and namespace in other branches
- 8.3 src/Routing/RouteSubscriber.php \Drupal\administerusersbyrole\Routing\RouteSubscriber::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/
Routing/ RouteSubscriber.php, line 16
Class
- RouteSubscriber
- Listens to the dynamic route events.
Namespace
Drupal\administerusersbyrole\RoutingCode
public function alterRoutes(RouteCollection $collection) {
// Provide additional access according to our permissions.
if ($route = $collection
->get('entity.user.collection')) {
$perm = $route
->getRequirement('_permission') . '+access users overview';
$route
->setRequirement('_permission', $perm);
}
// The route 'user.multiple_cancel_confirm' specifically checks for access
// to each user. Hence in theory we could remove the requirement entirely,
// but it's safer to set a basic permission.
if ($route = $collection
->get('user.multiple_cancel_confirm')) {
$perm = $route
->getRequirement('_permission') . '+access users overview';
$route
->setRequirement('_permission', $perm);
}
}