diff -u b/core/lib/Drupal/Core/Routing/MatcherDumper.php b/core/lib/Drupal/Core/Routing/MatcherDumper.php --- b/core/lib/Drupal/Core/Routing/MatcherDumper.php +++ b/core/lib/Drupal/Core/Routing/MatcherDumper.php @@ -67,0 +68,12 @@ + * {@inheritdoc} + */ + public function addRoutes(RouteCollection $routes) { + if (empty($this->routes)) { + $this->routes = $routes; + } + else { + $this->routes->addCollection($routes); + } + } + + /** diff -u b/core/lib/Drupal/Core/Routing/MatcherDumperInterface.php b/core/lib/Drupal/Core/Routing/MatcherDumperInterface.php --- b/core/lib/Drupal/Core/Routing/MatcherDumperInterface.php +++ b/core/lib/Drupal/Core/Routing/MatcherDumperInterface.php @@ -25,2 +25,10 @@ + /** + * Adds additional routes to be dumped. + * + * @param \Symfony\Component\Routing\RouteCollection $routes + * A collection of routes to add to this dumper. + */ + public function addRoutes(RouteCollection $routes); + } diff -u b/core/modules/system/lib/Drupal/system/Tests/Routing/MatcherDumperTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/MatcherDumperTest.php --- b/core/modules/system/lib/Drupal/system/Tests/Routing/MatcherDumperTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/MatcherDumperTest.php @@ -86,12 +86,12 @@ $route = new Route('test'); $collection = new RouteCollection(); $collection->add('test_route', $route); - $dumper->setRoutes($collection); + $dumper->addRoutes($collection); $route = new Route('test2'); $collection2 = new RouteCollection(); $collection2->add('test_route2', $route); - $dumper->setRoutes($collection2); + $dumper->addRoutes($collection2); // Merge the two collections together so we can test them. $collection->addCollection(clone $collection2);