comparison core/lib/Drupal/Core/Routing/RouteSubscriberBase.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Core\Routing;
4
5 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
6 use Symfony\Component\Routing\RouteCollection;
7
8 /**
9 * Provides a base implementation for RouteSubscriber.
10 */
11 abstract class RouteSubscriberBase implements EventSubscriberInterface {
12
13 /**
14 * Alters existing routes for a specific collection.
15 *
16 * @param \Symfony\Component\Routing\RouteCollection $collection
17 * The route collection for adding routes.
18 */
19 abstract protected function alterRoutes(RouteCollection $collection);
20
21 /**
22 * {@inheritdoc}
23 */
24 public static function getSubscribedEvents() {
25 $events[RoutingEvents::ALTER] = 'onAlterRoutes';
26 return $events;
27 }
28
29 /**
30 * Delegates the route altering to self::alterRoutes().
31 *
32 * @param \Drupal\Core\Routing\RouteBuildEvent $event
33 * The route build event.
34 */
35 public function onAlterRoutes(RouteBuildEvent $event) {
36 $collection = $event->getRouteCollection();
37 $this->alterRoutes($collection);
38 }
39
40 }