diff --git a/core/lib/Drupal/Core/Routing/FinalMatcherInterface.php b/core/lib/Drupal/Core/Routing/FinalMatcherInterface.php index 56804465eb3..2c8c80082c5 100644 --- a/core/lib/Drupal/Core/Routing/FinalMatcherInterface.php +++ b/core/lib/Drupal/Core/Routing/FinalMatcherInterface.php @@ -10,6 +10,15 @@ use Symfony\Component\Routing\RouteCollection; */ interface FinalMatcherInterface { + /** + * Sets the route collection this matcher should use. + * + * @param RouteCollection $collection + * The collection against which to match. + * + * @return FinalMatcherInterface + * The current matcher. + */ public function setCollection(RouteCollection $collection); /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/MockFinalMatcher.php b/core/lib/Drupal/Core/Routing/FirstEntryFinalMatcher.php similarity index 64% rename from core/modules/system/lib/Drupal/system/Tests/Routing/MockFinalMatcher.php rename to core/lib/Drupal/Core/Routing/FirstEntryFinalMatcher.php index ca5d68be8bb..81880cfaf3f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/MockFinalMatcher.php +++ b/core/lib/Drupal/Core/Routing/FirstEntryFinalMatcher.php @@ -1,22 +1,34 @@ routes = $collection; @@ -25,7 +37,7 @@ class MockFinalMatcher implements FinalMatcherInterface { public function matchRequest(Request $request) { - // For testing purposes, just return whatever the first route is. + // Return whatever the first route in the collection is. foreach ($this->routes as $name => $route) { return array_merge($this->mergeDefaults(array(), $route->getDefaults()), array('_route' => $name)); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/HttpMethodMatcherTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/HttpMethodMatcherTest.php index 48210d3cd61..4b5a90cfe44 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/HttpMethodMatcherTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/HttpMethodMatcherTest.php @@ -15,6 +15,7 @@ use Symfony\Component\Routing\Exception\MethodNotAllowedException; use Drupal\simpletest\UnitTestBase; use Drupal\Core\Routing\HttpMethodMatcher; use Drupal\Core\Routing\NestedMatcher; +use Drupal\Core\Routing\FirstEntryFinalMatcher; use Exception; @@ -74,7 +75,7 @@ class HttpMethodMatcherTest extends UnitTestBase { $matcher->setInitialMatcher(new MockPathMatcher($this->fixtures->sampleRouteCollection())); $matcher->addPartialMatcher(new HttpMethodMatcher()); - $matcher->setFinalMatcher(new MockFinalMatcher()); + $matcher->setFinalMatcher(new FirstEntryFinalMatcher()); $request = Request::create('/path/one', 'GET');