Mercurial > hg > cmmr2012-drupal-site
view vendor/chi-teck/drupal-code-generator/templates/d8/service/route-subscriber.twig @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
line wrap: on
line source
<?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; } }