Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / Routing / RouteSubscriberBase.php
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 }