3 namespace Drupal\Core\Routing;
5 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
6 use Symfony\Component\Routing\RouteCollection;
9 * Provides a base implementation for RouteSubscriber.
11 abstract class RouteSubscriberBase implements EventSubscriberInterface {
14 * Alters existing routes for a specific collection.
16 * @param \Symfony\Component\Routing\RouteCollection $collection
17 * The route collection for adding routes.
19 abstract protected function alterRoutes(RouteCollection $collection);
24 public static function getSubscribedEvents() {
25 $events[RoutingEvents::ALTER] = 'onAlterRoutes';
30 * Delegates the route altering to self::alterRoutes().
32 * @param \Drupal\Core\Routing\RouteBuildEvent $event
33 * The route build event.
35 public function onAlterRoutes(RouteBuildEvent $event) {
36 $collection = $event->getRouteCollection();
37 $this->alterRoutes($collection);