Mercurial > hg > isophonics-drupal-site
view core/modules/system/src/EventSubscriber/AdminRouteSubscriber.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
line wrap: on
line source
<?php namespace Drupal\system\EventSubscriber; use Drupal\Core\Routing\RouteSubscriberBase; use Drupal\Core\Routing\RoutingEvents; use Symfony\Component\Routing\RouteCollection; /** * Adds the _admin_route option to each admin route. */ class AdminRouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ protected function alterRoutes(RouteCollection $collection) { foreach ($collection->all() as $route) { if (strpos($route->getPath(), '/admin') === 0 && !$route->hasOption('_admin_route')) { $route->setOption('_admin_route', TRUE); } } } /** * {@inheritdoc} */ public static function getSubscribedEvents() { $events = parent::getSubscribedEvents(); // Use a lower priority than \Drupal\field_ui\Routing\RouteSubscriber or // \Drupal\views\EventSubscriber\RouteSubscriber to ensure we add the option // to their routes. $events[RoutingEvents::ALTER] = ['onAlterRoutes', -200]; return $events; } }