Mercurial > hg > isophonics-drupal-site
annotate core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.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 |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Core\EventSubscriber; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Routing\LazyRouteEnhancer; |
Chris@0 | 6 use Drupal\Core\Routing\RouteBuildEvent; |
Chris@0 | 7 use Drupal\Core\Routing\RoutingEvents; |
Chris@0 | 8 use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
Chris@0 | 9 |
Chris@0 | 10 /** |
Chris@0 | 11 * Listens to the new routes before they get saved. |
Chris@0 | 12 */ |
Chris@0 | 13 class RouteEnhancerSubscriber implements EventSubscriberInterface { |
Chris@0 | 14 |
Chris@0 | 15 /** |
Chris@0 | 16 * @var \Drupal\Core\Routing\LazyRouteEnhancer |
Chris@0 | 17 */ |
Chris@0 | 18 protected $routeEnhancer; |
Chris@0 | 19 |
Chris@0 | 20 /** |
Chris@0 | 21 * Constructs the RouteEnhancerSubscriber object. |
Chris@0 | 22 * |
Chris@0 | 23 * @param \Drupal\Core\Routing\LazyRouteEnhancer $route_enhancer |
Chris@0 | 24 * The lazy route enhancer. |
Chris@0 | 25 */ |
Chris@0 | 26 public function __construct(LazyRouteEnhancer $route_enhancer) { |
Chris@0 | 27 $this->routeEnhancer = $route_enhancer; |
Chris@0 | 28 } |
Chris@0 | 29 |
Chris@0 | 30 /** |
Chris@0 | 31 * Adds the route_enhancer object to the route collection. |
Chris@0 | 32 * |
Chris@0 | 33 * @param \Drupal\Core\Routing\RouteBuildEvent $event |
Chris@0 | 34 * The route build event. |
Chris@0 | 35 */ |
Chris@0 | 36 public function onRouteAlter(RouteBuildEvent $event) { |
Chris@0 | 37 $this->routeEnhancer->setEnhancers($event->getRouteCollection()); |
Chris@0 | 38 } |
Chris@0 | 39 |
Chris@0 | 40 /** |
Chris@0 | 41 * {@inheritdoc} |
Chris@0 | 42 */ |
Chris@0 | 43 public static function getSubscribedEvents() { |
Chris@0 | 44 $events[RoutingEvents::ALTER][] = ['onRouteAlter', -300]; |
Chris@0 | 45 return $events; |
Chris@0 | 46 } |
Chris@0 | 47 |
Chris@0 | 48 } |