RouteSubscriber.php in Vocabulary Permissions Per Role 8
File
src/Routing/RouteSubscriber.php
View source
<?php
namespace Drupal\vppr\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
class RouteSubscriber extends RouteSubscriberBase {
public function alterRoutes(RouteCollection $collection) {
if ($route = $collection
->get('entity.taxonomy_vocabulary.collection')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
$route
->setOption('op', 'index');
}
if ($route = $collection
->get('entity.taxonomy_vocabulary.overview_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
$route
->setOption('op', 'list terms');
}
if ($route = $collection
->get('entity.taxonomy_vocabulary.edit_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
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',
]);
}
if ($route = $collection
->get('entity.taxonomy_vocabulary.delete_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
if ($route = $collection
->get('entity.taxonomy_term.delete_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
if ($route = $collection
->get('entity.taxonomy_vocabulary.reset_form')) {
$route
->setRequirements([
'_custom_access' => '\\vppr_route_access',
]);
}
$route
->setOption('op', '');
}
}