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/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php index 22e82d2..39f9ceb 100644 --- a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php @@ -9,25 +9,19 @@ use Drupal\Component\Utility\String; use Drupal\Core\Routing\RouteBuildEvent; -use Drupal\Core\Routing\RoutingEvents; +use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Cmf\Component\Routing\RouteObjectInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\Routing\RouteCollection; /** * Provides a route subscriber which checks for invalid pattern variables. */ -class SpecialAttributesRouteSubscriber implements EventSubscriberInterface { +class SpecialAttributesRouteSubscriber extends RouteSubscriberBase { /** - * Checks for invalid pattern variables. - * - * @param \Drupal\Core\Routing\RouteBuildEvent $event - * The event containing the build routes. - * - * @throws \InvalidArgumentException - * Thrown when a reserved variable was used as route variable. + * {@inheritdoc} */ - public function onRouteBuilding(RouteBuildEvent $event) { + protected function alterRoutes(RouteCollection $collection, $module) { $special_variables = array( '_account', 'system_path', @@ -41,7 +35,7 @@ public function onRouteBuilding(RouteBuildEvent $event) { '_form', ); - foreach ($event->getRouteCollection()->all() as $route) { + foreach ($collection->all() as $route) { if ($not_allowed_variables = array_intersect($route->compile()->getVariables(), $special_variables)) { $placeholders = array('@variables' => implode(', ', $not_allowed_variables)); drupal_set_message(String::format('The following variables are reserved names by drupal: @variables', $placeholders)); @@ -53,11 +47,17 @@ public function onRouteBuilding(RouteBuildEvent $event) { } /** - * {@inheritdoc} + * Delegates the route altering to self::alterRoutes(). + * + * @param \Drupal\Core\Routing\RouteBuildEvent $event + * The route build event. + * + * @return bool + * Returns TRUE if the variables were succesfully replaced, otherwise FALSE. */ - static function getSubscribedEvents() { - $events[RoutingEvents::ALTER][] = 'onRouteBuilding'; - return $events; + public function onAlterRoutes(RouteBuildEvent $event) { + $collection = $event->getRouteCollection(); + return $this->alterRoutes($collection, $event->getModule()); } } diff --git a/core/lib/Drupal/Core/Routing/RouteSubscriberBase.php b/core/lib/Drupal/Core/Routing/RouteSubscriberBase.php new file mode 100644 index 0000000..615a820 --- /dev/null +++ b/core/lib/Drupal/Core/Routing/RouteSubscriberBase.php @@ -0,0 +1,74 @@ +add($route);. + * + * @param \Symfony\Component\Routing\RouteCollection $collection + * The route collection for adding routes. + */ + protected function routes(RouteCollection $collection) { + } + + /** + * Alters existing routes for a specific collection. + * + * @param \Symfony\Component\Routing\RouteCollection $collection + * The route collection for adding routes. + * @param string $module + * The module these routes belong to. For dynamically added routes, the + * module name will be 'dynamic_routes'. + */ + protected function alterRoutes(RouteCollection $collection, $module) { + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events[RoutingEvents::DYNAMIC] = 'onDynamicRoutes'; + $events[RoutingEvents::ALTER] = 'onAlterRoutes'; + return $events; + } + + /** + * Delegates the route gathering to self::routes(). + * + * @param \Drupal\Core\Routing\RouteBuildEvent $event + * The route build event. + */ + public function onDynamicRoutes(RouteBuildEvent $event) { + $collection = $event->getRouteCollection(); + $this->routes($collection); + } + + /** + * Delegates the route altering to self::alterRoutes(). + * + * @param \Drupal\Core\Routing\RouteBuildEvent $event + * The route build event. + */ + public function onAlterRoutes(RouteBuildEvent $event) { + $collection = $event->getRouteCollection(); + $this->alterRoutes($collection, $event->getModule()); + } + +} diff --git a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php index 1931191..cdf3d98 100644 --- a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php +++ b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php @@ -7,36 +7,19 @@ namespace Drupal\block\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\DependencyInjection\ContainerInterface; +use Symfony\Component\Routing\RouteCollection; /** * Listens to the dynamic route events. */ -class RouteSubscriber implements EventSubscriberInterface { +class RouteSubscriber extends RouteSubscriberBase { /** - * Implements EventSubscriberInterface::getSubscribedEvents(). + * {@inheritdoc} */ - public static function getSubscribedEvents() { - $events[RoutingEvents::DYNAMIC] = 'routes'; - return $events; - } - - /** - * Generate dynamic routes for various block pages. - * - * @param \Drupal\Core\Routing\RouteBuildEvent $event - * The route building event. - * - * @return \Symfony\Component\Routing\RouteCollection - * The route collection that contains the new dynamic route. - */ - public function routes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); + protected function routes(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 cb4858c..ae4a55c 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 @@ -7,16 +7,15 @@ namespace Drupal\content_translation\Routing; -use Drupal\Core\Routing\RouteBuildEvent; -use Drupal\Core\Routing\RoutingEvents; use Drupal\Core\Entity\EntityManager; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; /** * Subscriber for entity translation routes. */ -class ContentTranslationRouteSubscriber implements EventSubscriberInterface { +class ContentTranslationRouteSubscriber extends RouteSubscriberBase { /** * The entity type manager. @@ -38,16 +37,7 @@ public function __construct(EntityManager $entityManager) { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { - $events[RoutingEvents::DYNAMIC] = 'routes'; - return $events; - } - - /** - * Adds routes for entity translations. - */ - public function routes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); + protected function routes(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 456e1fd..6e3b003 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 @@ -7,16 +7,15 @@ namespace Drupal\field_ui\Routing; -use Drupal\Core\Routing\RouteBuildEvent; -use Drupal\Core\Routing\RoutingEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Routing\Route; use Drupal\Core\Entity\EntityManager; +use Drupal\Core\Routing\RouteSubscriberBase; +use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; /** * Subscriber for Field UI routes. */ -class RouteSubscriber implements EventSubscriberInterface { +class RouteSubscriber extends RouteSubscriberBase { /** * The entity type manager @@ -38,16 +37,7 @@ public function __construct(EntityManager $manager) { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { - $events[RoutingEvents::DYNAMIC] = 'routes'; - return $events; - } - - /** - * Adds routes for the Field UI. - */ - public function routes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); + protected function routes(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 2524522..59fbb75 100644 --- a/core/modules/image/lib/Drupal/image/EventSubscriber/RouteSubscriber.php +++ b/core/modules/image/lib/Drupal/image/EventSubscriber/RouteSubscriber.php @@ -7,38 +7,23 @@ namespace Drupal\image\EventSubscriber; -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; /** * Defines a route subscriber to register a url for serving image styles. */ -class RouteSubscriber implements EventSubscriberInterface { +class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { - $events[RoutingEvents::DYNAMIC] = 'dynamicRoutes'; - return $events; - } - - /** - * Registers dynamic routes for image styles. - * - * 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 will - * be bypassed. - * - * @param \Drupal\Core\Routing\RouteBuildEvent $event - * The route building event. - */ - public function dynamicRoutes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); - + protected function routes(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 + // will be bypassed. $directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(); $route = new Route('/' . $directory_path . '/styles/{image_style}/{scheme}', diff --git a/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php b/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php index 325f472..34fd75d 100644 --- a/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php +++ b/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php @@ -1,22 +1,21 @@ getRouteCollection(); + protected function routes(RouteCollection $collection) { $enabled_resources = $this->config->get('rest.settings')->load()->get('resources'); // Iterate over all enabled resource plugins. @@ -88,12 +82,4 @@ public function dynamicRoutes(RouteBuildEvent $event) { } } - /** - * Implements EventSubscriberInterface::getSubscribedEvents(). - */ - static function getSubscribedEvents() { - $events[RoutingEvents::DYNAMIC] = 'dynamicRoutes'; - return $events; - } } - diff --git a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php index 5564ba4..0061d83 100644 --- a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php +++ b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php @@ -2,21 +2,20 @@ /** * @file - * Contains Drupal\search\Routing\SearchRouteSubscriber + * Contains \Drupal\search\Routing\SearchRouteSubscriber. */ namespace Drupal\search\Routing; -use Drupal\Core\Routing\RouteBuildEvent; -use Drupal\Core\Routing\RoutingEvents; +use Drupal\Core\Routing\RouteSubscriberBase; use Drupal\search\SearchPluginManager; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; /** * Provides dynamic routes for search. */ -class SearchRouteSubscriber implements EventSubscriberInterface { +class SearchRouteSubscriber extends RouteSubscriberBase { /** * The search plugin manager. @@ -38,20 +37,7 @@ public function __construct(SearchPluginManager $search_plugin_manager) { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { - $events[RoutingEvents::DYNAMIC] = 'routes'; - return $events; - } - - /** - * Adds routes for search. - * - * @param \Drupal\Core\Routing\RouteBuildEvent $event - * The route building event. - */ - public function routes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); - + protected function routes(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 600e6af..c7c265c 100644 --- a/core/modules/system/lib/Drupal/system/Routing/RouteSubscriber.php +++ b/core/modules/system/lib/Drupal/system/Routing/RouteSubscriber.php @@ -7,32 +7,19 @@ namespace Drupal\system\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; /** * Event subscriber for routes. */ -class RouteSubscriber implements EventSubscriberInterface { +class RouteSubscriber extends RouteSubscriberBase { /** - * Implements EventSubscriberInterface::getSubscribedEvents(). + * {@inheritdoc} */ - static function getSubscribedEvents() { - $events[RoutingEvents::DYNAMIC] = 'createSystemThemeRoutes'; - return $events; - } - - /** - * Adds dynamic system theme routes. - * - * @param \Drupal\Core\Routing\RouteBuildEvent $event - * The route building event. - */ - public function createSystemThemeRoutes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); + protected function routes(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 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'; diff --git a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php index 2ab8cdb..f3320db 100644 --- a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php +++ b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php @@ -8,15 +8,13 @@ namespace Drupal\views\EventSubscriber; use Drupal\Component\Utility\MapArray; -use Drupal\Component\Utility\NestedArray; use Drupal\Core\DestructableInterface; use Drupal\Core\Entity\EntityManager; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; -use Drupal\Core\Routing\RouteBuildEvent; -use Drupal\Core\Routing\RoutingEvents; +use Drupal\Core\Routing\RouteSubscriberBase; use Drupal\views\Plugin\views\display\DisplayRouterInterface; use Drupal\views\ViewExecutable; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\Routing\RouteCollection; /** * Builds up the routes of all views. @@ -27,7 +25,7 @@ * * @see \Drupal\views\Plugin\views\display\PathPluginBase */ -class RouteSubscriber implements EventSubscriberInterface, DestructableInterface { +class RouteSubscriber extends RouteSubscriberBase implements DestructableInterface { /** * Stores a list of view,display IDs which haven't be used in the alter event. @@ -78,15 +76,6 @@ public function reset() { } /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() { - $events[RoutingEvents::DYNAMIC] = 'dynamicRoutes'; - $events[RoutingEvents::ALTER] = 'alterRoutes'; - return $events; - } - - /** * Gets all the views and display IDs using a route. */ protected function getViewsDisplayIDsWithRoute() { @@ -106,14 +95,9 @@ protected function getViewsDisplayIDsWithRoute() { } /** - * Adds routes defined by all views. - * - * @param \Drupal\Core\Routing\RouteBuildEvent $event - * The route building event. + * {@inheritdoc} */ - public function dynamicRoutes(RouteBuildEvent $event) { - $collection = $event->getRouteCollection(); - + protected function routes(RouteCollection $collection) { foreach ($this->getViewsDisplayIDsWithRoute() as $pair) { list($view_id, $display_id) = explode('.', $pair); $view = $this->viewStorageController->load($view_id); @@ -134,12 +118,9 @@ public function dynamicRoutes(RouteBuildEvent $event) { } /** - * Alters existing routes. - * - * @param \Drupal\Core\Routing\RouteBuildEvent $event - * The route building event. + * {@inheritdoc} */ - public function alterRoutes(RouteBuildEvent $event) { + protected function alterRoutes(RouteCollection $collection, $module) { foreach ($this->getViewsDisplayIDsWithRoute() as $pair) { list($view_id, $display_id) = explode('.', $pair); $view = $this->viewStorageController->load($view_id); @@ -149,7 +130,7 @@ public function alterRoutes(RouteBuildEvent $event) { if ($display instanceof DisplayRouterInterface) { // If the display returns TRUE a route item was found, so it does not // have to be added. - $view_route_names = $display->alterRoutes($event->getRouteCollection()); + $view_route_names = $display->alterRoutes($collection); $this->viewRouteNames += $view_route_names; foreach ($view_route_names as $id_display => $route_name) { unset($this->viewsDisplayPairs[$id_display]); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php index f420943..3e5b590 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php @@ -95,7 +95,7 @@ public function testPageResponses() { public function testPageRouterItems() { $subscriber = new RouteSubscriber($this->container->get('entity.manager'), $this->container->get('state')); $collection = new RouteCollection(); - $subscriber->dynamicRoutes(new RouteBuildEvent($collection, 'dynamic_routes')); + $subscriber->onDynamicRoutes(new RouteBuildEvent($collection, 'dynamic_routes')); // Check the controller defaults. foreach ($collection as $id => $route) { diff --git a/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php b/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php index a6a6d7c..fad9eac 100644 --- a/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php @@ -75,9 +75,9 @@ protected function setUp() { } /** - * Tests the dynamicRoutes method. + * Tests the onDynamicRoutes method. * - * @see \Drupal\views\EventSubscriber\RouteSubscriber::dynamicRoutes() + * @see \Drupal\views\EventSubscriber\RouteSubscriber::onDynamicRoutes() */ public function testDynamicRoutes() { $collection = new RouteCollection(); @@ -92,7 +92,7 @@ public function testDynamicRoutes() { ->method('collectRoutes') ->will($this->returnValue(array('test_id.page_2' => 'views.test_id.page_2'))); - $this->assertNull($this->routeSubscriber->dynamicRoutes($route_event)); + $this->assertNull($this->routeSubscriber->onDynamicRoutes($route_event)); $this->state->expects($this->once()) ->method('set') @@ -101,11 +101,11 @@ public function testDynamicRoutes() { } /** - * Tests the alterRoutes method. + * Tests the onAlterRoutes method. * - * @see \Drupal\views\EventSubscriber\RouteSubscriber::alterRoutes() + * @see \Drupal\views\EventSubscriber\RouteSubscriber::onAlterRoutes() */ - public function testAlterRoutes() { + public function testOnAlterRoutes() { $collection = new RouteCollection(); $collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\Tests\Core\Controller\TestController'))); $route_2 = new Route('test_route/example', array('_controller' => 'Drupal\Tests\Core\Controller\TestController')); @@ -130,12 +130,12 @@ public function testAlterRoutes() { ->method('collectRoutes') ->will($this->returnValue(array('test_id.page_2' => 'views.test_id.page_2'))); - $this->assertNull($this->routeSubscriber->alterRoutes($route_event)); + $this->assertNull($this->routeSubscriber->onAlterRoutes($route_event)); // Ensure that after the alterRoutes the collectRoutes method is just called // once (not for page_1 anymore). - $this->assertNull($this->routeSubscriber->dynamicRoutes($route_event)); + $this->assertNull($this->routeSubscriber->onDynamicRoutes($route_event)); $this->state->expects($this->once()) ->method('set') diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php index aea9434..0018ffd 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php @@ -69,7 +69,7 @@ public function testRemoveRoute($route_name, array $requirements, $removed) { $event = new RouteBuildEvent($collection, 'test'); $route_subscriber = new ModuleRouteSubscriber($this->moduleHandler); - $route_subscriber->removeRoutes($event); + $route_subscriber->onAlterRoutes($event); if ($removed) { $this->assertNull($collection->get($route_name)); diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php index 7555768..f003327 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php @@ -84,7 +84,7 @@ public function providerTestOnRouteBuildingValidVariables() { } /** - * Tests the onRouteBuilding method for valid variables. + * Tests the onAlterRoutes method for valid variables. * * @param \Symfony\Component\Routing\Route $route * The route to check. @@ -95,11 +95,11 @@ public function testOnRouteBuildingValidVariables(Route $route) { $route_collection = new RouteCollection(); $route_collection->add('test', $route); $event = new RouteBuildEvent($route_collection, 'test'); - $this->assertTrue($this->specialAttributesRouteSubscriber->onRouteBuilding($event)); + $this->assertTrue($this->specialAttributesRouteSubscriber->onAlterRoutes($event)); } /** - * Tests the onRouteBuilding method for invalid variables. + * Tests the onAlterRoutes method for invalid variables. * * @param \Symfony\Component\Routing\Route $route * The route to check. @@ -110,7 +110,7 @@ public function testOnRouteBuildingInvalidVariables(Route $route) { $route_collection = new RouteCollection(); $route_collection->add('test', $route); $event = new RouteBuildEvent($route_collection, 'test'); - $this->assertFalse($this->specialAttributesRouteSubscriber->onRouteBuilding($event)); + $this->assertFalse($this->specialAttributesRouteSubscriber->onAlterRoutes($event)); } }