diff --git a/core/lib/Drupal/Core/Routing/RouteSubscriberBase.php b/core/lib/Drupal/Core/Routing/RouteSubscriberBase.php index 615a820..9077588 100644 --- a/core/lib/Drupal/Core/Routing/RouteSubscriberBase.php +++ b/core/lib/Drupal/Core/Routing/RouteSubscriberBase.php @@ -25,7 +25,7 @@ * @param \Symfony\Component\Routing\RouteCollection $collection * The route collection for adding routes. */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { } /** @@ -50,14 +50,14 @@ public static function getSubscribedEvents() { } /** - * Delegates the route gathering to self::routes(). + * Delegates the route gathering to self::getRoutes(). * * @param \Drupal\Core\Routing\RouteBuildEvent $event * The route build event. */ public function onDynamicRoutes(RouteBuildEvent $event) { $collection = $event->getRouteCollection(); - $this->routes($collection); + $this->getRoutes($collection); } /** diff --git a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php index cdf3d98..d468c8f 100644 --- a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php +++ b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php @@ -19,7 +19,7 @@ class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { foreach (list_themes(TRUE) as $key => $theme) { // The block entity listing page. $route = new Route( diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php b/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php index ae4a55c..2a766eb 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php @@ -37,7 +37,7 @@ public function __construct(EntityManager $entityManager) { /** * {@inheritdoc} */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { if ($entity_info['translatable'] && isset($entity_info['translation'])) { $path = '/' . str_replace($entity_info['menu_path_wildcard'], '{' . $entity_type . '}', $entity_info['menu_base_path']) . '/translations'; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php b/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php index 6e3b003..6a206a8 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php @@ -37,7 +37,7 @@ public function __construct(EntityManager $manager) { /** * {@inheritdoc} */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { foreach ($this->manager->getDefinitions() as $entity_type => $entity_info) { $defaults = array(); if ($entity_info['fieldable'] && isset($entity_info['route_base_path'])) { diff --git a/core/modules/image/lib/Drupal/image/EventSubscriber/RouteSubscriber.php b/core/modules/image/lib/Drupal/image/EventSubscriber/RouteSubscriber.php index 59fbb75..87ca159 100644 --- a/core/modules/image/lib/Drupal/image/EventSubscriber/RouteSubscriber.php +++ b/core/modules/image/lib/Drupal/image/EventSubscriber/RouteSubscriber.php @@ -19,7 +19,7 @@ class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { // Generate image derivatives of publicly available files. If clean URLs are // disabled image derivatives will always be served through the menu system. // If clean URLs are enabled and the image derivative already exists, PHP diff --git a/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php b/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php index 34fd75d..a4f5264 100644 --- a/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php +++ b/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php @@ -47,7 +47,7 @@ public function __construct(ResourcePluginManager $manager, ConfigFactory $confi /** * {@inheritdoc} */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { $enabled_resources = $this->config->get('rest.settings')->load()->get('resources'); // Iterate over all enabled resource plugins. diff --git a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php index 0061d83..9aaab6e 100644 --- a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php +++ b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php @@ -37,7 +37,7 @@ public function __construct(SearchPluginManager $search_plugin_manager) { /** * {@inheritdoc} */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { foreach ($this->searchManager->getActiveDefinitions() as $plugin_id => $search_info) { $path = 'search/' . $search_info['path'] . '/{keys}'; $defaults = array( diff --git a/core/modules/system/lib/Drupal/system/Routing/RouteSubscriber.php b/core/modules/system/lib/Drupal/system/Routing/RouteSubscriber.php index c7c265c..585fb56 100644 --- a/core/modules/system/lib/Drupal/system/Routing/RouteSubscriber.php +++ b/core/modules/system/lib/Drupal/system/Routing/RouteSubscriber.php @@ -19,7 +19,7 @@ class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { foreach (list_themes() as $theme) { if (!empty($theme->status)) { $route = new Route('admin/appearance/settings/' . $theme->name, array( 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 ae09b55..fb468a4 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 @@ -19,7 +19,7 @@ class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { $types = entity_test_entity_types(); $types[] = 'entity_test_render'; diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/EventSubscriber/FormTestEventSubscriber.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/EventSubscriber/FormTestEventSubscriber.php index 11e5a7a..ea306a5 100644 --- a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/EventSubscriber/FormTestEventSubscriber.php +++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/EventSubscriber/FormTestEventSubscriber.php @@ -7,18 +7,18 @@ namespace Drupal\form_test\EventSubscriber; -use Drupal\Core\Routing\RouteBuildEvent; +use Drupal\Core\Routing\RouteSubscriberBase; use Drupal\Core\Routing\RoutingEvents; use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\Routing\Route; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\Routing\RouteCollection; /** * Test event subscriber to add new attributes to the request. */ -class FormTestEventSubscriber implements EventSubscriberInterface { +class FormTestEventSubscriber extends RouteSubscriberBase { /** * The module handler. @@ -51,18 +51,15 @@ public function onKernelRequest(GetResponseEvent $event) { */ public static function getSubscribedEvents() { $events[KernelEvents::REQUEST][] = array('onKernelRequest'); - $events[RoutingEvents::DYNAMIC] = 'routes'; - + $events[RoutingEvents::DYNAMIC] = 'onDynamicRoutes'; + $events[RoutingEvents::ALTER] = 'onAlterRoutes'; return $events; } /** * Adds routes for the Form Tests. */ - public function routes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); - $defaults = array(); - + protected function getRoutes(RouteCollection $collection) { if ($this->moduleHandler->moduleExists('node')) { $route = new Route( "form-test/two-instances-of-same-form", diff --git a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php index f3320db..a39d027 100644 --- a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php +++ b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php @@ -97,7 +97,7 @@ protected function getViewsDisplayIDsWithRoute() { /** * {@inheritdoc} */ - protected function routes(RouteCollection $collection) { + protected function getRoutes(RouteCollection $collection) { foreach ($this->getViewsDisplayIDsWithRoute() as $pair) { list($view_id, $display_id) = explode('.', $pair); $view = $this->viewStorageController->load($view_id);