diff --git a/core/lib/Drupal/Core/Routing/RoutePreloader.php b/core/lib/Drupal/Core/Routing/RoutePreloader.php index 9a16aaf..d0050c3 100644 --- a/core/lib/Drupal/Core/Routing/RoutePreloader.php +++ b/core/lib/Drupal/Core/Routing/RoutePreloader.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Routing; use Drupal\Core\ContentNegotiation; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Drupal\Core\KeyValueStore\StateInterface; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -99,7 +98,7 @@ protected function loadNonAdminRoutes() { public function onAlterRoutes(RouteBuildEvent $event) { $collection = $event->getRouteCollection(); foreach ($collection->all() as $name => $route) { - if (strpos($route->getPath(), '/admin') === FALSE) { + if (strpos($route->getPath(), '/admin') !== 0) { $this->nonAdminRoutesOnRebuild[] = $name; } } diff --git a/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php b/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php index 7b24ba2..3154d36 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php @@ -94,6 +94,28 @@ public function testOnAlterRoutesWithAdminRoutes() { } /** + * Tests onAlterRoutes with "admin" appearing in the path. + */ + public function testOnAlterRoutesWithAdminPathNoAdminRoute() { + $event = $this->getMockBuilder('Drupal\Core\Routing\RouteBuildEvent') + ->disableOriginalConstructor() + ->getMock(); + $route_collection = new RouteCollection(); + $route_collection->add('test', new Route('/foo/admin/foo', array('_content' => 'Drupal\ExampleController'))); + $route_collection->add('test2', new Route('/bar/admin/bar', array('_content' => 'Drupal\ExampleController'))); + $event->expects($this->once()) + ->method('getRouteCollection') + ->will($this->returnValue($route_collection)); + + $this->state->expects($this->once()) + ->method('set') + ->with('routing.non_admin_routes', array('test', 'test2')); + $this->preloader->onAlterRoutes($event); + $this->preloader->onFinishedRoutes(new Event()); + } + + + /** * Tests onAlterRoutes with admin routes and non admin routes. */ public function testOnAlterRoutesWithNonAdminRoutes() {