Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
39
vendor/chi-teck/drupal-code-generator/templates/d8/service/route-subscriber.twig
vendored
Normal file
39
vendor/chi-teck/drupal-code-generator/templates/d8/service/route-subscriber.twig
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\{{ machine_name }}\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Routing\RouteSubscriberBase;
|
||||
use Drupal\Core\Routing\RoutingEvents;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* {{ name }} route subscriber.
|
||||
*/
|
||||
class {{ class }} extends RouteSubscriberBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function alterRoutes(RouteCollection $collection) {
|
||||
foreach ($collection->all() as $route) {
|
||||
// Hide taxonomy pages from unprivileged users.
|
||||
if (strpos($route->getPath(), '/taxonomy/term') === 0) {
|
||||
$route->setRequirement('_role', 'administrator');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
$events = parent::getSubscribedEvents();
|
||||
|
||||
// Use a lower priority than \Drupal\views\EventSubscriber\RouteSubscriber
|
||||
// to ensure the requirement will be added to its routes.
|
||||
$events[RoutingEvents::ALTER] = ['onAlterRoutes', -300];
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue