diff --git a/core/lib/Drupal/Core/EventSubscriber/ModuleRouteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ModuleRouteSubscriber.php index 5bb903e..49f1a12 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ModuleRouteSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ModuleRouteSubscriber.php @@ -8,14 +8,13 @@ namespace Drupal\Core\EventSubscriber; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Routing\RouteBuildEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Drupal\Core\Routing\RoutingEvents; +use Drupal\Core\Routing\RouteSubscriberBase; +use Symfony\Component\Routing\RouteCollection; /** * A route subscriber to remove routes that depend on modules being enabled. */ -class ModuleRouteSubscriber implements EventSubscriberInterface { +class ModuleRouteSubscriber extends RouteSubscriberBase { /** * The module handler. @@ -37,20 +36,7 @@ public function __construct(ModuleHandlerInterface $module_handler) { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { - $events[RoutingEvents::ALTER] = 'removeRoutes'; - return $events; - } - - /** - * Removes any routes that have an unmet module dependency. - * - * @param \Drupal\Core\Routing\RouteBuildEvent $event - * The route building event. - */ - public function removeRoutes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); - + protected function alterRoutes(RouteCollection $collection, $module) { foreach ($collection as $name => $route) { if ($route->hasRequirement('_module_dependencies')) { $modules = $route->getRequirement('_module_dependencies'); diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Routing/RouteSubscriber.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Routing/RouteSubscriber.php index 8834b4a..ae09b55 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Routing/RouteSubscriber.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Routing/RouteSubscriber.php @@ -7,29 +7,19 @@ namespace Drupal\entity_test\Routing; -use Drupal\Core\Routing\RouteBuildEvent; -use Drupal\Core\Routing\RoutingEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; /** * Subscriber for Entity Test routes. */ -class RouteSubscriber implements EventSubscriberInterface { +class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { - $events[RoutingEvents::DYNAMIC] = 'routes'; - return $events; - } - - /** - * Adds routes for the Entity Test. - */ - public function routes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); + protected function routes(RouteCollection $collection) { $types = entity_test_entity_types(); $types[] = 'entity_test_render';