class RouteSubscriber in Vocabulary Permissions Per Role 8
Class RouteSubscriber.
@package Drupal\vppr\Routing
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\vppr\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
1 service uses RouteSubscriber
File
- src/
Routing/ RouteSubscriber.php, line 13
Namespace
Drupal\vppr\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
public function alterRoutes(RouteCollection $collection) {
// For all the necessary admin routes grant permission
// (admin/structure/taxonomy).
if ($route = $collection
->get('entity.taxonomy_vocabulary.collection')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
$route
->setOption('op', 'index');
}
// Overview page.
// admin/structure/taxonomy/manage/{taxonomy_vocabulary}/overview.
if ($route = $collection
->get('entity.taxonomy_vocabulary.overview_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
$route
->setOption('op', 'list terms');
}
// Vocabulary Edit form -
// admin/structure/taxonomy/manage/{taxonomy_vocabulary}.
if ($route = $collection
->get('entity.taxonomy_vocabulary.edit_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
// Term Edit page - taxonomy/term/{taxonomy_term}/edit.
if ($route = $collection
->get('entity.taxonomy_term.edit_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
if ($route = $collection
->get('entity.taxonomy_term.add_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
// Vocabulary delete - admin/structure/taxonomy/%vocabulary/delete.
if ($route = $collection
->get('entity.taxonomy_vocabulary.delete_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
// Term delete - taxonomy/term/{taxonomy_term}/delete.
if ($route = $collection
->get('entity.taxonomy_term.delete_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
// Reset order.
if ($route = $collection
->get('entity.taxonomy_vocabulary.reset_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
$route
->setOption('op', '');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
public | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriberBase:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | 5 |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |