From 37893880799b9dbb8bc365e7ebda02162020a37b Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Tue, 23 Jun 2020 10:35:08 +0100
Subject: [PATCH] Issue #2917331 by catch, martin107, Deepak Goyal, longwave,
 andypost, ravi.shankar, alexpott, daffie, larowlan: Decouple from Symfony CMF

---
 core/authorize.php                            |  2 +-
 core/includes/install.core.inc                |  2 +-
 core/lib/Drupal/Core/Access/AccessManager.php |  2 +-
 .../Entity/Enhancer/EntityRouteEnhancer.php   |  2 +-
 .../OptionsRequestSubscriber.php              |  6 +-
 .../SpecialAttributesRouteSubscriber.php      |  2 +-
 .../ParamConverter/ParamConverterManager.php  |  2 +-
 core/lib/Drupal/Core/Path/PathValidator.php   |  2 +-
 .../Enhancer/EntityRevisionRouteEnhancer.php  |  2 +-
 .../Routing/Enhancer/FormRouteEnhancer.php    |  2 +-
 .../Enhancer/ParamConversionEnhancer.php      |  2 +-
 .../Drupal/Core/Routing/EnhancerInterface.php | 18 +++-
 .../Drupal/Core/Routing/FilterInterface.php   | 24 ++++-
 .../Core/Routing/LazyRouteCollection.php      | 68 ++++++++++++++
 core/lib/Drupal/Core/Routing/RouteMatch.php   |  1 -
 .../Core/Routing/RouteObjectInterface.php     | 29 ++++++
 .../lib/Drupal/Core/Routing/RouteProvider.php | 44 +++++++--
 .../Core/Routing/RouteProviderInterface.php   | 66 +++++++++++++
 .../Core/Routing/RouteProviderLazyBuilder.php | 32 ++++++-
 core/lib/Drupal/Core/Routing/Router.php       | 17 +---
 .../Core/Routing/UrlGeneratorInterface.php    |  4 +-
 core/lib/Drupal/Core/Routing/UrlMatcher.php   | 16 +++-
 .../Core/Test/FunctionalTestSetupTrait.php    |  2 +-
 core/lib/Drupal/Core/Update/UpdateKernel.php  |  2 +-
 core/lib/Drupal/Core/Url.php                  |  2 +-
 .../src/Routing/FieldUiRouteEnhancer.php      |  2 +-
 .../ParamConverter/EntityUuidConverter.php    |  2 +-
 .../ResourceVersionRouteEnhancer.php          |  2 +-
 core/modules/jsonapi/src/Routing/Routes.php   |  2 +-
 .../ResourceResponseValidatorTest.php         |  2 +-
 .../tests/src/Unit/Routing/RoutesTest.php     |  2 +-
 .../LanguageNegotiationContentEntity.php      |  2 +-
 .../LanguageNegotiationContentEntityTest.php  |  2 +-
 .../src/Kernel/EntityUrlLanguageTest.php      |  2 +-
 ...enuLinkContentCacheabilityBubblingTest.php |  2 +-
 .../src/Tests/Routing/MockRouteProvider.php   |  2 +-
 .../src/TestControllers.php                   |  2 +-
 .../tests/src/Functional/Theme/ThemeTest.php  |  2 +-
 .../src/Kernel/Block/SystemMenuBlockTest.php  |  2 +-
 .../PathBasedBreadcrumbBuilderTest.php        |  2 +-
 .../LanguageNegotiationUserAdmin.php          |  2 +-
 .../Unit/Routing/ViewPageControllerTest.php   |  2 +-
 core/modules/views_ui/src/ViewUI.php          |  2 +-
 .../Core/RouteProcessor/RouteNoneTest.php     |  2 +-
 .../RouteProcessorCurrentIntegrationTest.php  |  2 +-
 .../Core/Routing/RouteProviderTest.php        | 46 +++++++++
 .../Drupal/KernelTests/KernelTestBase.php     |  2 +-
 .../Drupal/KernelTests/RouteProvider.php      | 19 +---
 .../Tests/Core/Access/AccessManagerTest.php   |  2 +-
 .../AuthenticationManagerTest.php             |  2 +-
 .../EntityRevisionRouteEnhancerTest.php       |  2 +-
 .../Enhancer/ParamConversionEnhancerTest.php  |  2 +-
 .../Enhancer/EntityRouteEnhancerTest.php      |  2 +-
 .../OptionsRequestSubscriberTest.php          |  2 +-
 .../SpecialAttributesRouteSubscriberTest.php  |  2 +-
 .../Tests/Core/Menu/MenuActiveTrailTest.php   |  2 +-
 .../ParamConverterManagerTest.php             |  2 +-
 .../Tests/Core/Path/PathValidatorTest.php     |  2 +-
 .../Core/Routing/AccessAwareRouterTest.php    | 28 +++---
 .../Core/Routing/CurrentRouteMatchTest.php    |  2 +-
 .../Core/Routing/LazyRouteCollectionTest.php  | 94 +++++++++++++++++++
 .../Tests/Core/Routing/RouteMatchTest.php     |  2 +-
 core/tests/Drupal/Tests/Core/UrlTest.php      |  2 +-
 63 files changed, 493 insertions(+), 113 deletions(-)
 create mode 100644 core/lib/Drupal/Core/Routing/LazyRouteCollection.php
 create mode 100644 core/lib/Drupal/Core/Routing/RouteObjectInterface.php
 create mode 100644 core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php

diff --git a/core/authorize.php b/core/authorize.php
index e0b7c4f192fa..9ffe8e2b7d3e 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -27,7 +27,7 @@
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
 use Drupal\Core\Site\Settings;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\Routing\Route;
 
 // Change the directory to the Drupal root.
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index b6bc1e1c0bb3..d610fdd25c03 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -32,7 +32,7 @@
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\Core\Url;
 use Drupal\language\Entity\ConfigurableLanguage;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
diff --git a/core/lib/Drupal/Core/Access/AccessManager.php b/core/lib/Drupal/Core/Access/AccessManager.php
index d2b7e55f99ab..36dec5b65c61 100644
--- a/core/lib/Drupal/Core/Access/AccessManager.php
+++ b/core/lib/Drupal/Core/Access/AccessManager.php
@@ -11,7 +11,7 @@
 use Drupal\Component\Utility\ArgumentsResolverInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Exception\RouteNotFoundException;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 
 /**
  * Attaches access check services to routes and runs them on request.
diff --git a/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php b/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php
index f383fbc98640..aa0b41a2fa9e 100644
--- a/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php
+++ b/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php
@@ -4,7 +4,7 @@
 
 use Drupal\Core\Routing\EnhancerInterface;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\Routing\Route;
 
 /**
diff --git a/core/lib/Drupal/Core/EventSubscriber/OptionsRequestSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/OptionsRequestSubscriber.php
index 9520283a9898..18982a6d6e4b 100644
--- a/core/lib/Drupal/Core/EventSubscriber/OptionsRequestSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/OptionsRequestSubscriber.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Core\EventSubscriber;
 
-use Symfony\Cmf\Component\Routing\RouteProviderInterface;
+use Drupal\Core\Routing\RouteProviderInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -20,14 +20,14 @@ class OptionsRequestSubscriber implements EventSubscriberInterface {
   /**
    * The route provider.
    *
-   * @var \Symfony\Cmf\Component\Routing\RouteProviderInterface
+   * @var \Drupal\Core\Routing\RouteProviderInterface
    */
   protected $routeProvider;
 
   /**
    * Creates a new OptionsRequestSubscriber instance.
    *
-   * @param \Symfony\Cmf\Component\Routing\RouteProviderInterface $route_provider
+   * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
    *   The route provider.
    */
   public function __construct(RouteProviderInterface $route_provider) {
diff --git a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php
index 0f40c5a58eba..67b2fba2b6c5 100644
--- a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php
@@ -4,7 +4,7 @@
 
 use Drupal\Core\Routing\RouteBuildEvent;
 use Drupal\Core\Routing\RouteSubscriberBase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\Routing\RouteCollection;
 
 /**
diff --git a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php
index 944bd5304c9d..c3ca6ba879ea 100644
--- a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php
+++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Core\ParamConverter;
 
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\Routing\RouteCollection;
 
 /**
diff --git a/core/lib/Drupal/Core/Path/PathValidator.php b/core/lib/Drupal/Core/Path/PathValidator.php
index efce47305a20..58976df17756 100644
--- a/core/lib/Drupal/Core/Path/PathValidator.php
+++ b/core/lib/Drupal/Core/Path/PathValidator.php
@@ -9,7 +9,7 @@
 use Drupal\Core\Routing\RequestContext;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Url;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
 use Symfony\Component\Routing\Exception\MethodNotAllowedException;
diff --git a/core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php
index d54338f44914..bdd52cbdd30d 100644
--- a/core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php
+++ b/core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php
@@ -3,7 +3,7 @@
 namespace Drupal\Core\Routing\Enhancer;
 
 use Drupal\Core\Routing\EnhancerInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php
index c812178d2924..9e9df9f71dd2 100644
--- a/core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php
+++ b/core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php
@@ -3,7 +3,7 @@
 namespace Drupal\Core\Routing\Enhancer;
 
 use Drupal\Core\Routing\EnhancerInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php
index aa2b8c830c86..507366bc7c05 100644
--- a/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php
+++ b/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php
@@ -5,7 +5,7 @@
 use Drupal\Core\ParamConverter\ParamConverterManagerInterface;
 use Drupal\Core\ParamConverter\ParamNotConvertedException;
 use Drupal\Core\Routing\EnhancerInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
diff --git a/core/lib/Drupal/Core/Routing/EnhancerInterface.php b/core/lib/Drupal/Core/Routing/EnhancerInterface.php
index 3ddee667526f..3439a4a17201 100644
--- a/core/lib/Drupal/Core/Routing/EnhancerInterface.php
+++ b/core/lib/Drupal/Core/Routing/EnhancerInterface.php
@@ -2,11 +2,25 @@
 
 namespace Drupal\Core\Routing;
 
-use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * A route enhance service to determine route enhance rules.
  */
-interface EnhancerInterface extends RouteEnhancerInterface {
+interface EnhancerInterface {
+
+  /**
+   * Updates the defaults for a route definition based on the request.
+   *
+   * @param array $defaults
+   *   The defaults, maps to '_defaults' in the route definition YAML.
+   * @param \Symfony\Component\HttpFoundation\Request $request
+   *   The Request instance.
+   *
+   * @return array
+   *   The modified defaults. Each enhancer MUST return the
+   *   $defaults but may add or remove values.
+   */
+  public function enhance(array $defaults, Request $request);
 
 }
diff --git a/core/lib/Drupal/Core/Routing/FilterInterface.php b/core/lib/Drupal/Core/Routing/FilterInterface.php
index 73c9f83a265c..ad446a69940f 100644
--- a/core/lib/Drupal/Core/Routing/FilterInterface.php
+++ b/core/lib/Drupal/Core/Routing/FilterInterface.php
@@ -2,11 +2,31 @@
 
 namespace Drupal\Core\Routing;
 
-use Symfony\Cmf\Component\Routing\NestedMatcher\RouteFilterInterface;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\RouteCollection;
 
 /**
  * A route filter service to filter down the collection of route instances.
  */
-interface FilterInterface extends RouteFilterInterface {
+interface FilterInterface {
+
+  /**
+    * Filters the route collection against a request and returns all matching
+    * routes.
+    *
+    * @param \Symfony\Component\Routing\RouteCollection $collection
+    *   The collection against which to match.
+    * @param \Symfony\Component\HttpFoundation\Request $request
+    *   A Request object against which to match.
+    *
+    * @return \Symfony\Component\Routing\RouteCollection
+    *   A non-empty RouteCollection of matched routes
+    *
+    * @throws ResourceNotFoundException
+    *   If none of the routes in $collection matches $request. This is a
+    *   performance optimization to not continue the match process when a match
+    *   will no longer be possible.
+    */
+  public function filter(RouteCollection $collection, Request $request);
 
 }
diff --git a/core/lib/Drupal/Core/Routing/LazyRouteCollection.php b/core/lib/Drupal/Core/Routing/LazyRouteCollection.php
new file mode 100644
index 000000000000..5f9706efe7fa
--- /dev/null
+++ b/core/lib/Drupal/Core/Routing/LazyRouteCollection.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Drupal\Core\Routing;
+
+use Symfony\Component\Routing\Exception\RouteNotFoundException;
+use Symfony\Component\Routing\RouteCollection;
+
+class LazyRouteCollection extends RouteCollection {
+  /**
+   * The route provider for this generator.
+   *
+   * @var \Symfony\Component\Routing\RouteProviderInterface
+   */
+  protected $provider;
+
+  /**
+   * Constructs a LazyRouteCollection.
+   */
+  public function __construct(RouteProviderInterface $provider) {
+    $this->provider = $provider;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getIterator() {
+    return new \ArrayIterator($this->all());
+  }
+
+  /**
+   * Gets the number of Routes in this collection.
+   *
+   * @return int
+   *   The number of routes
+   */
+  public function count() {
+    return count($this->all());
+  }
+
+  /**
+   * Returns all routes in this collection.
+   *
+   * @return \Symfony\Component\Routing\Route[]
+   *   An array of routes
+   */
+  public function all() {
+    return $this->provider->getRoutesByNames(NULL);
+  }
+
+  /**
+   * Gets a route by name.
+   *
+   * @param string $name
+   *   The route name
+   *
+   * @return \Symfony\Component\Routing\Route|null
+   *   A Route instance or null when not found
+   */
+  public function get($name) {
+    try {
+      return $this->provider->getRouteByName($name);
+    }
+    catch (RouteNotFoundException $e) {
+      return;
+    }
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Routing/RouteMatch.php b/core/lib/Drupal/Core/Routing/RouteMatch.php
index 10c444758fef..e00be3554f6b 100644
--- a/core/lib/Drupal/Core/Routing/RouteMatch.php
+++ b/core/lib/Drupal/Core/Routing/RouteMatch.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Core\Routing;
 
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
diff --git a/core/lib/Drupal/Core/Routing/RouteObjectInterface.php b/core/lib/Drupal/Core/Routing/RouteObjectInterface.php
new file mode 100644
index 000000000000..e7afacd62431
--- /dev/null
+++ b/core/lib/Drupal/Core/Routing/RouteObjectInterface.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Drupal\Core\Routing;
+
+/**
+ * Provides constants used for retrieving matched routes.
+ */
+interface RouteObjectInterface {
+
+  /**
+   * Key for the route name.
+   *
+   * @var string
+   */
+  const ROUTE_NAME = '_route';
+
+  /**
+   * Key for the route object.
+   *
+   * @var string
+   */
+  const ROUTE_OBJECT = '_route_object';
+
+  /**
+   * Key for the controller.
+   */
+  const CONTROLLER_NAME = '_controller';
+
+}
diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php
index c372b7bdac56..4920dbafbdfc 100644
--- a/core/lib/Drupal/Core/Routing/RouteProvider.php
+++ b/core/lib/Drupal/Core/Routing/RouteProvider.php
@@ -10,8 +10,6 @@
 use Drupal\Core\Path\CurrentPathStack;
 use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
 use Drupal\Core\State\StateInterface;
-use Symfony\Cmf\Component\Routing\PagedRouteCollection;
-use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Exception\RouteNotFoundException;
@@ -21,7 +19,7 @@
 /**
  * A Route Provider front-end for all Drupal-stored routes.
  */
-class RouteProvider implements CacheableRouteProviderInterface, PreloadableRouteProviderInterface, PagedRouteProviderInterface, EventSubscriberInterface {
+class RouteProvider implements CacheableRouteProviderInterface, PreloadableRouteProviderInterface, EventSubscriberInterface {
 
   /**
    * The database connection from which to read route information.
@@ -401,7 +399,16 @@ protected function routeProviderRouteCompare(array $a, array $b) {
    * {@inheritdoc}
    */
   public function getAllRoutes() {
-    return new PagedRouteCollection($this);
+    $select = $this->connection->select($this->tableName, 'router')
+      ->fields('router', ['name', 'route']);
+    $routes = $select->execute()->fetchAllKeyed();
+
+    $result = [];
+    foreach ($routes as $name => $route) {
+      $result[$name] = unserialize($route);
+    }
+
+    return $result;
   }
 
   /**
@@ -422,9 +429,25 @@ public static function getSubscribedEvents() {
   }
 
   /**
-   * {@inheritdoc}
+   * Returns a chunk of routes.
+   *
+   * Should only be used in conjunction with an iterator.
+   *
+   * @param int $offset
+   *   The query offset.
+   * @param int $length
+   *   The number of records.
+   *
+   * @return \Symfony\Component\Routing\Route[]
+   *   Routes keyed by the route name.
+   *
+   * @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct
+   *   replacement is provided.
+   *
+   * @see https://www.drupal.org/node/3151009
    */
   public function getRoutesPaged($offset, $length = NULL) {
+    @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009', E_USER_DEPRECATED);
     $select = $this->connection->select($this->tableName, 'router')
       ->fields('router', ['name', 'route']);
 
@@ -443,9 +466,18 @@ public function getRoutesPaged($offset, $length = NULL) {
   }
 
   /**
-   * {@inheritdoc}
+   * Gets the total count of routes provided by the router.
+   *
+   * @return int
+   *   Number of routes.
+   *
+   * @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct
+   *   replacement is provided.
+   *
+   * @see https://www.drupal.org/node/3151009
    */
   public function getRoutesCount() {
+    @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009', E_USER_DEPRECATED);
     return $this->connection->query("SELECT COUNT(*) FROM {" . $this->connection->escapeTable($this->tableName) . "}")->fetchField();
   }
 
diff --git a/core/lib/Drupal/Core/Routing/RouteProviderInterface.php b/core/lib/Drupal/Core/Routing/RouteProviderInterface.php
index f53593a82e18..cc6632a1166a 100644
--- a/core/lib/Drupal/Core/Routing/RouteProviderInterface.php
+++ b/core/lib/Drupal/Core/Routing/RouteProviderInterface.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Routing;
 
+use Symfony\Component\HttpFoundation\Request;
 use Symfony\Cmf\Component\Routing\RouteProviderInterface as RouteProviderBaseInterface;
 
 /**
@@ -11,6 +12,71 @@
  */
 interface RouteProviderInterface extends RouteProviderBaseInterface {
 
+  /**
+   * Finds routes that may potentially match the request.
+   *
+   * This may return a mixed list of class instances, but all routes returned
+   * must extend the core Symfony route. The classes may also implement
+   * RouteObjectInterface to link to a content document.
+   *
+   * This method may not throw an exception based on implementation specific
+   * restrictions on the url. That case is considered a not found - returning
+   * an empty array. Exceptions are only used to abort the whole request in
+   * case something is seriously broken, like the storage backend being down.
+   *
+   * Note that implementations may not implement an optimal matching
+   * algorithm, simply a reasonable first pass.  That allows for potentially
+   * very large route sets to be filtered down to likely candidates, which
+   * may then be filtered in memory more completely.
+   *
+   * @param \Symfony\Component\HttpFoundation\Request $request
+   *   A request against which to match
+   *
+   * @return \Symfony\Component\Routing\RouteCollection
+   *   All Routes that could potentially match $request.
+   *   Empty collection if nothing can match
+   */
+  public function getRouteCollectionForRequest(Request $request);
+
+  /**
+   * Find the route using the provided route name.
+   *
+   * @param string $name
+   *   The route name to fetch
+   *
+   * @return \Symfony\Component\Routing\Route
+   *   The Symfony route object.
+   *
+   * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException
+   *   If a matching route cannot be found.
+   */
+  public function getRouteByName($name);
+
+  /**
+   * Find many routes by their names using the provided list of names.
+   *
+   * Note that this method may not throw an exception if some of the routes
+   * are not found or are not actually Route instances. It will just return the
+   * list of those Route instances it found.
+   *
+   * This method exists in order to allow performance optimizations. The
+   * simple implementation could be to just repeatedly call
+   * $this->getRouteByName() while catching and ignoring eventual exceptions.
+   *
+   * If $names is null, this method SHOULD return a collection of all routes
+   * known to this provider. If there are many routes to be expected, usage of
+   * a lazy loading collection is recommended. A provider MAY only return a
+   * subset of routes to e.g. support paging or other concepts.
+   *
+   * @param array|null $names
+   *   The list of names to retrieve, In case of null, the provider will
+   *   determine what routes to return
+   *
+   * @return \Symfony\Component\Routing\Route[]
+   *   Iterable list with the keys being the names from the $names array
+   */
+  public function getRoutesByNames($names);
+
   /**
    * Get all routes which match a certain pattern.
    *
diff --git a/core/lib/Drupal/Core/Routing/RouteProviderLazyBuilder.php b/core/lib/Drupal/Core/Routing/RouteProviderLazyBuilder.php
index a2cb8c578513..d5a55a9a3a5c 100644
--- a/core/lib/Drupal/Core/Routing/RouteProviderLazyBuilder.php
+++ b/core/lib/Drupal/Core/Routing/RouteProviderLazyBuilder.php
@@ -2,14 +2,13 @@
 
 namespace Drupal\Core\Routing;
 
-use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
  * A Route Provider front-end for all Drupal-stored routes.
  */
-class RouteProviderLazyBuilder implements PreloadableRouteProviderInterface, PagedRouteProviderInterface, EventSubscriberInterface {
+class RouteProviderLazyBuilder implements PreloadableRouteProviderInterface, EventSubscriberInterface {
 
   /**
    * The route provider service.
@@ -122,16 +121,41 @@ public function reset() {
   }
 
   /**
-   * {@inheritdoc}
+   * Returns a chunk of routes.
+   *
+   * Should only be used in conjunction with an iterator.
+   *
+   * @param int $offset
+   *   The query offset.
+   * @param int $length
+   *   The number of records.
+   *
+   * @return \Symfony\Component\Routing\Route[]
+   *   Routes keyed by the route name.
+   *
+   * @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct
+   *   replacement is provided.
+   *
+   * @see https://www.drupal.org/node/3151009
    */
   public function getRoutesPaged($offset, $length = NULL) {
+    @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009', E_USER_DEPRECATED);
     return $this->getRouteProvider()->getRoutesPaged($offset, $length);
   }
 
   /**
-   * {@inheritdoc}
+   * Gets the total count of routes provided by the router.
+   *
+   * @return int
+   *   Number of routes.
+   *
+   * @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct
+   *   replacement is provided.
+   *
+   * @see https://www.drupal.org/node/3151009
    */
   public function getRoutesCount() {
+    @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009', E_USER_DEPRECATED);
     return $this->getRouteProvider()->getRoutesCount();
   }
 
diff --git a/core/lib/Drupal/Core/Routing/Router.php b/core/lib/Drupal/Core/Routing/Router.php
index d1586e42b165..8b649a3ec2a2 100644
--- a/core/lib/Drupal/Core/Routing/Router.php
+++ b/core/lib/Drupal/Core/Routing/Router.php
@@ -3,8 +3,6 @@
 namespace Drupal\Core\Routing;
 
 use Drupal\Core\Path\CurrentPathStack;
-use Symfony\Cmf\Component\Routing\LazyRouteCollection;
-use Symfony\Cmf\Component\Routing\RouteProviderInterface as BaseRouteProviderInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Exception\MethodNotAllowedException;
 use Symfony\Component\Routing\Exception\ResourceNotFoundException;
@@ -29,22 +27,13 @@
  *    regex. See ::matchCollection().
  * 4. Enhance the list of route attributes, for example loading entity objects.
  *    See ::applyRouteEnhancers().
- *
- * This implementation uses ideas of the following routers:
- * - \Symfony\Cmf\Component\Routing\DynamicRouter
- * - \Drupal\Core\Routing\UrlMatcher
- * - \Symfony\Cmf\Component\Routing\NestedMatcher\NestedMatcher
- *
- * @see \Symfony\Cmf\Component\Routing\DynamicRouter
- * @see \Drupal\Core\Routing\UrlMatcher
- * @see \Symfony\Cmf\Component\Routing\NestedMatcher\NestedMatcher
  */
 class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterface {
 
   /**
    * The route provider responsible for the first-pass match.
    *
-   * @var \Symfony\Cmf\Component\Routing\RouteProviderInterface
+   * @var \Drupal\Core\Routing\RouteProviderInterface
    */
   protected $routeProvider;
 
@@ -72,14 +61,14 @@ class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterf
   /**
    * Constructs a new Router.
    *
-   * @param \Symfony\Cmf\Component\Routing\RouteProviderInterface $route_provider
+   * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
    *   The route provider.
    * @param \Drupal\Core\Path\CurrentPathStack $current_path
    *   The current path stack.
    * @param \Symfony\Component\Routing\Generator\UrlGeneratorInterface $url_generator
    *   The URL generator.
    */
-  public function __construct(BaseRouteProviderInterface $route_provider, CurrentPathStack $current_path, BaseUrlGeneratorInterface $url_generator) {
+  public function __construct(RouteProviderInterface $route_provider, CurrentPathStack $current_path, BaseUrlGeneratorInterface $url_generator) {
     parent::__construct($current_path);
     $this->routeProvider = $route_provider;
     $this->urlGenerator = $url_generator;
diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
index e63383df5f89..bbc91de1d195 100644
--- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
+++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Core\Routing;
 
-use Symfony\Cmf\Component\Routing\VersatileGeneratorInterface;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface as SymfonyUrlGeneratorInterface;
 
 /**
  * Defines an interface for generating a url from a route or system path.
  *
  * Provides additional methods and options not present in the base interface.
  */
-interface UrlGeneratorInterface extends VersatileGeneratorInterface {
+interface UrlGeneratorInterface extends SymfonyUrlGeneratorInterface {
 
   /**
    * Gets the internal path (system path) for a route.
diff --git a/core/lib/Drupal/Core/Routing/UrlMatcher.php b/core/lib/Drupal/Core/Routing/UrlMatcher.php
index 90569033687c..bc9a63f5f6ee 100644
--- a/core/lib/Drupal/Core/Routing/UrlMatcher.php
+++ b/core/lib/Drupal/Core/Routing/UrlMatcher.php
@@ -4,8 +4,9 @@
 
 use Drupal\Core\Path\CurrentPathStack;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Route;
 use Symfony\Component\Routing\RouteCollection;
-use Symfony\Cmf\Component\Routing\NestedMatcher\UrlMatcher as BaseUrlMatcher;
+use Symfony\Component\Routing\Matcher\UrlMatcher as BaseUrlMatcher;
 
 /**
  * Drupal-specific URL Matcher; handles the Drupal "system path" mapping.
@@ -41,4 +42,17 @@ public function finalMatch(RouteCollection $collection, Request $request) {
     return $this->match($this->currentPath->getPath($request));
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  protected function getAttributes(Route $route, $name, array $attributes) {
+    if ($route instanceof RouteObjectInterface && is_string($route->getRouteKey())) {
+      $name = $route->getRouteKey();
+    }
+    $attributes[RouteObjectInterface::ROUTE_NAME] = $name;
+    $attributes[RouteObjectInterface::ROUTE_OBJECT] = $route;
+
+    return $this->mergeDefaults($attributes, $route->getDefaults());
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
index a10af1e48c33..504797507615 100644
--- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
+++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
@@ -21,7 +21,7 @@
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Yaml\Yaml as SymfonyYaml;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\Routing\Route;
 
 /**
diff --git a/core/lib/Drupal/Core/Update/UpdateKernel.php b/core/lib/Drupal/Core/Update/UpdateKernel.php
index 2b74dabb67be..edcee199607b 100644
--- a/core/lib/Drupal/Core/Update/UpdateKernel.php
+++ b/core/lib/Drupal/Core/Update/UpdateKernel.php
@@ -6,7 +6,7 @@
 use Drupal\Core\Session\AnonymousUserSession;
 use Drupal\Core\Site\Settings;
 use Drupal\Core\StackMiddleware\ReverseProxyMiddleware;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php
index 82c2c600b376..09b988f413ec 100644
--- a/core/lib/Drupal/Core/Url.php
+++ b/core/lib/Drupal/Core/Url.php
@@ -10,7 +10,7 @@
 use Drupal\Core\Routing\UrlGeneratorInterface;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Utility\UnroutedUrlAssemblerInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
diff --git a/core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php b/core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php
index c7e51950e8ae..dac2ca0d473c 100644
--- a/core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php
+++ b/core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php
@@ -3,7 +3,7 @@
 namespace Drupal\field_ui\Routing;
 
 use Drupal\Core\Routing\EnhancerInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
diff --git a/core/modules/jsonapi/src/ParamConverter/EntityUuidConverter.php b/core/modules/jsonapi/src/ParamConverter/EntityUuidConverter.php
index abc10cff4fc2..1b4ef83e436c 100644
--- a/core/modules/jsonapi/src/ParamConverter/EntityUuidConverter.php
+++ b/core/modules/jsonapi/src/ParamConverter/EntityUuidConverter.php
@@ -7,7 +7,7 @@
 use Drupal\Core\Language\LanguageManagerInterface;
 use Drupal\Core\ParamConverter\EntityConverter;
 use Drupal\jsonapi\Routing\Routes;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/modules/jsonapi/src/Revisions/ResourceVersionRouteEnhancer.php b/core/modules/jsonapi/src/Revisions/ResourceVersionRouteEnhancer.php
index 50cb8b8c5d71..8da175894cec 100644
--- a/core/modules/jsonapi/src/Revisions/ResourceVersionRouteEnhancer.php
+++ b/core/modules/jsonapi/src/Revisions/ResourceVersionRouteEnhancer.php
@@ -8,7 +8,7 @@
 use Drupal\Core\Http\Exception\CacheableHttpException;
 use Drupal\Core\Routing\EnhancerInterface;
 use Drupal\jsonapi\Routing\Routes;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
 
diff --git a/core/modules/jsonapi/src/Routing/Routes.php b/core/modules/jsonapi/src/Routing/Routes.php
index e592f007aef6..7ba8338112cd 100644
--- a/core/modules/jsonapi/src/Routing/Routes.php
+++ b/core/modules/jsonapi/src/Routing/Routes.php
@@ -8,7 +8,7 @@
 use Drupal\jsonapi\ParamConverter\ResourceTypeConverter;
 use Drupal\jsonapi\ResourceType\ResourceType;
 use Drupal\jsonapi\ResourceType\ResourceTypeRepositoryInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\Routing\Route;
 use Symfony\Component\Routing\RouteCollection;
diff --git a/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php b/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
index 6f45d5ecd933..2dcafb191df2 100644
--- a/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
+++ b/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
@@ -12,7 +12,7 @@
 use Drupal\Tests\UnitTestCase;
 use Prophecy\Argument;
 use Psr\Log\LoggerInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
diff --git a/core/modules/jsonapi/tests/src/Unit/Routing/RoutesTest.php b/core/modules/jsonapi/tests/src/Unit/Routing/RoutesTest.php
index 4a70512a0d88..e6c08a655955 100644
--- a/core/modules/jsonapi/tests/src/Unit/Routing/RoutesTest.php
+++ b/core/modules/jsonapi/tests/src/Unit/Routing/RoutesTest.php
@@ -8,7 +8,7 @@
 use Drupal\jsonapi\ResourceType\ResourceTypeRepository;
 use Drupal\jsonapi\Routing\Routes;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php
index a28506caebeb..87e12c7d4b9e 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php
@@ -10,7 +10,7 @@
 use Drupal\Core\Url;
 use Drupal\language\LanguageNegotiationMethodBase;
 use Drupal\language\LanguageSwitcherInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
diff --git a/core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php b/core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php
index 7c973368a399..9695cd576967 100644
--- a/core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php
@@ -9,7 +9,7 @@
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity;
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
 use Drupal\Tests\BrowserTestBase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php b/core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php
index 03669cc3cdfe..9e60aa721cd7 100644
--- a/core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php
+++ b/core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php
@@ -7,7 +7,7 @@
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity;
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/modules/menu_link_content/tests/src/Kernel/MenuLinkContentCacheabilityBubblingTest.php b/core/modules/menu_link_content/tests/src/Kernel/MenuLinkContentCacheabilityBubblingTest.php
index 9701bcf8d114..1b9ae65ffe34 100644
--- a/core/modules/menu_link_content/tests/src/Kernel/MenuLinkContentCacheabilityBubblingTest.php
+++ b/core/modules/menu_link_content/tests/src/Kernel/MenuLinkContentCacheabilityBubblingTest.php
@@ -10,7 +10,7 @@
 use Drupal\menu_link_content\Entity\MenuLinkContent;
 use Drupal\Tests\user\Traits\UserCreationTrait;
 use Drupal\user\Entity\User;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/modules/system/src/Tests/Routing/MockRouteProvider.php b/core/modules/system/src/Tests/Routing/MockRouteProvider.php
index 5612ddd75bf5..7c34358dec6b 100644
--- a/core/modules/system/src/Tests/Routing/MockRouteProvider.php
+++ b/core/modules/system/src/Tests/Routing/MockRouteProvider.php
@@ -30,7 +30,7 @@ public function __construct(RouteCollection $routes) {
   }
 
   /**
-   * Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRouteCollectionForRequest().
+   * Implements \Drupal\Core\Routing\RouteProviderInterface::getRouteCollectionForRequest().
    *
    * Simply return all routes to prevent
    * \Symfony\Component\Routing\Exception\ResourceNotFoundException.
diff --git a/core/modules/system/tests/modules/router_test_directory/src/TestControllers.php b/core/modules/system/tests/modules/router_test_directory/src/TestControllers.php
index fe228a336b64..e8e0604e3ad4 100644
--- a/core/modules/system/tests/modules/router_test_directory/src/TestControllers.php
+++ b/core/modules/system/tests/modules/router_test_directory/src/TestControllers.php
@@ -5,7 +5,7 @@
 use Drupal\Core\Cache\CacheableResponse;
 use Drupal\Core\ParamConverter\ParamNotConvertedException;
 use Drupal\user\UserInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
 use Laminas\Diactoros\Response\HtmlResponse;
diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeTest.php
index 1c65277f2705..0cd5dc479be2 100644
--- a/core/modules/system/tests/src/Functional/Theme/ThemeTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/ThemeTest.php
@@ -4,7 +4,7 @@
 
 use Drupal\Component\Serialization\Json;
 use Drupal\Tests\BrowserTestBase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
index 6ac0e03d3887..b6ea41a1790b 100644
--- a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
+++ b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
@@ -10,7 +10,7 @@
 use Drupal\system\Tests\Routing\MockRouteProvider;
 use Drupal\Tests\Core\Menu\MenuLinkMock;
 use Drupal\user\Entity\User;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 use Symfony\Component\Routing\RouteCollection;
diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
index df5d756801f9..0b0c1e4aaad1 100644
--- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
+++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
@@ -17,7 +17,7 @@
 use Drupal\Core\Utility\LinkGeneratorInterface;
 use Drupal\system\PathBasedBreadcrumbBuilder;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\DependencyInjection\Container;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
diff --git a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php
index 4a829906ae96..fec14c3262b1 100644
--- a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php
+++ b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php
@@ -7,7 +7,7 @@
 use Drupal\Core\Routing\AdminContext;
 use Drupal\Core\Routing\StackedRouteMatchInterface;
 use Drupal\language\LanguageNegotiationMethodBase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
diff --git a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php
index 26d9ce7e110f..2250acf7b375 100644
--- a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php
+++ b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php
@@ -5,7 +5,7 @@
 use Drupal\Core\Routing\RouteMatch;
 use Drupal\Tests\UnitTestCase;
 use Drupal\views\Routing\ViewPageController;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php
index 056c7ea0c359..d1d7387abecb 100644
--- a/core/modules/views_ui/src/ViewUI.php
+++ b/core/modules/views_ui/src/ViewUI.php
@@ -16,7 +16,7 @@
 use Drupal\views\Plugin\views\query\Sql;
 use Drupal\views\Entity\View;
 use Drupal\views\ViewEntityInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
 
diff --git a/core/tests/Drupal/KernelTests/Core/RouteProcessor/RouteNoneTest.php b/core/tests/Drupal/KernelTests/Core/RouteProcessor/RouteNoneTest.php
index 922eefa25b5e..457602945c76 100644
--- a/core/tests/Drupal/KernelTests/Core/RouteProcessor/RouteNoneTest.php
+++ b/core/tests/Drupal/KernelTests/Core/RouteProcessor/RouteNoneTest.php
@@ -6,7 +6,7 @@
 use Drupal\Core\GeneratedUrl;
 use Drupal\Core\Render\BubbleableMetadata;
 use Drupal\KernelTests\KernelTestBase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/tests/Drupal/KernelTests/Core/RouteProcessor/RouteProcessorCurrentIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/RouteProcessor/RouteProcessorCurrentIntegrationTest.php
index 235af6e144f4..4da27e3669cf 100644
--- a/core/tests/Drupal/KernelTests/Core/RouteProcessor/RouteProcessorCurrentIntegrationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/RouteProcessor/RouteProcessorCurrentIntegrationTest.php
@@ -6,7 +6,7 @@
 use Drupal\Core\GeneratedUrl;
 use Drupal\Core\Render\BubbleableMetadata;
 use Drupal\KernelTests\KernelTestBase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
index e21a0ce9c018..41f9ca5ef084 100644
--- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
@@ -293,6 +293,32 @@ public function testDuplicateRoutePaths($path, $number, $expected_route_name = N
     }
   }
 
+  /**
+   * Confirms RouteProvider::getAllRoutes() extracts information correctly from the database.
+   */
+  public function testGetAllRoutes() {
+    $connection = Database::getConnection();
+    $provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
+
+    $this->fixtures->createTables($connection);
+
+    $dumper = new MatcherDumper($connection, $this->state, 'test_routes');
+    $dumper->addRoutes($this->fixtures->SampleRouteCollection());
+    $dumper->dump();
+
+    $sample_routes = $this->fixtures->staticSampleRouteCollection();
+    $expected_route_count = count($sample_routes);
+
+    $returned_routes = $provider->getAllRoutes();
+
+    $this->assertEqual($expected_route_count, count($returned_routes));
+
+    foreach ($returned_routes as $route_name => $route) {
+      $this->assertTrue(array_key_exists($route_name, $sample_routes));
+      $this->assertEquals($route->getPath(), $sample_routes[$route_name]['path']);
+    }
+  }
+
   /**
    * Confirms that a trailing slash on the request does not result in a 404.
    */
@@ -707,6 +733,9 @@ public function testGetRoutesByPatternWithLongPatterns() {
 
   /**
    * Tests getRoutesPaged().
+   *
+   * @group legacy
+   * @expectedDeprecation Drupal\Core\Routing\RouteProvider::getRoutesPaged() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009
    */
   public function testGetRoutesPaged() {
     $connection = Database::getConnection();
@@ -732,6 +761,23 @@ public function testGetRoutesPaged() {
     $this->assertEqual(array_keys($routes), array_slice(array_keys($fixture_routes), 1, 2));
   }
 
+  /**
+   * Tests getRoutesCount().
+   *
+   * @group legacy
+   * @expectedDeprecation Drupal\Core\Routing\RouteProvider::getRoutesCount() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009
+   */
+  public function testGetRoutesCount() {
+    $connection = Database::getConnection();
+    $provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
+
+    $this->fixtures->createTables($connection);
+    $dumper = new MatcherDumper($connection, $this->state, 'test_routes');
+    $dumper->addRoutes($this->fixtures->sampleRouteCollection());
+    $dumper->dump();
+    $this->assertEqual($provider->getRoutesCount(), 5);
+  }
+
 }
 
 class TestRouteProvider extends RouteProvider {
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index b1ebad5e32b6..5d13f5168373 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -28,7 +28,7 @@
 use Symfony\Component\HttpFoundation\Request;
 use org\bovigo\vfs\vfsStream;
 use org\bovigo\vfs\visitor\vfsStreamPrintVisitor;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\Routing\Route;
 
 /**
diff --git a/core/tests/Drupal/KernelTests/RouteProvider.php b/core/tests/Drupal/KernelTests/RouteProvider.php
index 4034da8896e0..f075dbae0d78 100644
--- a/core/tests/Drupal/KernelTests/RouteProvider.php
+++ b/core/tests/Drupal/KernelTests/RouteProvider.php
@@ -3,20 +3,19 @@
 namespace Drupal\KernelTests;
 
 use Drupal\Core\Routing\PreloadableRouteProviderInterface;
-use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Rebuilds the router when the provider is instantiated.
  */
-class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProviderInterface {
+class RouteProvider implements PreloadableRouteProviderInterface {
 
   use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
 
   /**
    * Loads the real route provider from the container and rebuilds the router.
    *
-   * @return \Drupal\Core\Routing\PreloadableRouteProviderInterface|\Symfony\Cmf\Component\Routing\PagedRouteProviderInterface|\Symfony\Component\EventDispatcher\EventSubscriberInterface
+   * @return \Drupal\Core\Routing\PreloadableRouteProviderInterface|\Symfony\Component\EventDispatcher\EventSubscriberInterface
    *   The route provider.
    */
   protected function lazyLoadItself() {
@@ -92,18 +91,4 @@ public function reset() {
     return $this->lazyLoadItself()->reset();
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function getRoutesPaged($offset, $length = NULL) {
-    return $this->lazyLoadItself()->getRoutesPaged($offset, $length);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function getRoutesCount() {
-    return $this->lazyLoadItself()->getRoutesCount();
-  }
-
 }
diff --git a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
index e1ea93364046..69ede129af76 100644
--- a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
@@ -17,7 +17,7 @@
 use Drupal\Core\Access\DefaultAccessCheck;
 use Drupal\Tests\UnitTestCase;
 use Drupal\router_test\Access\DefinedTestAccessCheck;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\Routing\Exception\RouteNotFoundException;
 use Symfony\Component\Routing\Route;
diff --git a/core/tests/Drupal/Tests/Core/Authentication/AuthenticationManagerTest.php b/core/tests/Drupal/Tests/Core/Authentication/AuthenticationManagerTest.php
index 8269796781ec..d580d8204e34 100644
--- a/core/tests/Drupal/Tests/Core/Authentication/AuthenticationManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Authentication/AuthenticationManagerTest.php
@@ -12,7 +12,7 @@
 use Drupal\Core\Authentication\AuthenticationProviderFilterInterface;
 use Drupal\Core\Authentication\AuthenticationProviderInterface;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/tests/Drupal/Tests/Core/Enhancer/EntityRevisionRouteEnhancerTest.php b/core/tests/Drupal/Tests/Core/Enhancer/EntityRevisionRouteEnhancerTest.php
index db481e8c8e07..a250594ee231 100644
--- a/core/tests/Drupal/Tests/Core/Enhancer/EntityRevisionRouteEnhancerTest.php
+++ b/core/tests/Drupal/Tests/Core/Enhancer/EntityRevisionRouteEnhancerTest.php
@@ -5,7 +5,7 @@
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Routing\Enhancer\EntityRevisionRouteEnhancer;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
index e46b934d10f1..148f846cd170 100644
--- a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
+++ b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
@@ -4,7 +4,7 @@
 
 use Drupal\Core\Routing\Enhancer\ParamConversionEnhancer;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
diff --git a/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php b/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php
index 8eed80ac0d1a..297628262cc8 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php
@@ -4,7 +4,7 @@
 
 use Drupal\Core\Entity\Enhancer\EntityRouteEnhancer;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
 
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php
index ee158c842423..6a2e7b6fd790 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php
@@ -4,7 +4,7 @@
 
 use Drupal\Core\EventSubscriber\OptionsRequestSubscriber;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteProviderInterface;
+use Drupal\Core\Routing\RouteProviderInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Event\RequestEvent;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
index 0aa466bddc48..16b18a76636e 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
@@ -6,7 +6,7 @@
 use Drupal\Core\Routing\RouteBuildEvent;
 use Drupal\Tests\UnitTestCase;
 use PHPUnit\Framework\Error\Warning;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\Routing\Route;
 use Symfony\Component\Routing\RouteCollection;
 
diff --git a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php
index 4b8e8134f904..cf0483cc5d19 100644
--- a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php
@@ -5,7 +5,7 @@
 use Drupal\Core\Menu\MenuActiveTrail;
 use Drupal\Core\Routing\CurrentRouteMatch;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\DependencyInjection\Container;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
diff --git a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
index 7c0feba2fe6b..d755a7839539 100644
--- a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
@@ -5,7 +5,7 @@
 use Drupal\Core\ParamConverter\ParamConverterManager;
 use Drupal\Core\ParamConverter\ParamNotConvertedException;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\Routing\Route;
 use Symfony\Component\Routing\RouteCollection;
 
diff --git a/core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php b/core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
index d595193eb69d..ae94ab15e2ff 100644
--- a/core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
@@ -5,7 +5,7 @@
 use Drupal\Core\ParamConverter\ParamNotConvertedException;
 use Drupal\Core\Path\PathValidator;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
 use Symfony\Component\Routing\Exception\MethodNotAllowedException;
diff --git a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
index a52f9735a374..1908fbe03175 100644
--- a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
@@ -6,7 +6,7 @@
 use Drupal\Core\Routing\AccessAwareRouter;
 use Drupal\Core\Routing\AccessAwareRouterInterface;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
 use Symfony\Component\Routing\Route;
@@ -23,9 +23,9 @@ class AccessAwareRouterTest extends UnitTestCase {
   protected $route;
 
   /**
-   * @var \Symfony\Cmf\Component\Routing\ChainRouter|\PHPUnit\Framework\MockObject\MockObject
+   * @var \Drupal\Core\Routing\Router|\PHPUnit\Framework\MockObject\MockObject
    */
-  protected $chainRouter;
+  protected $coreRouter;
 
   /**
    * @var \Drupal\Core\Access\AccessManagerInterface|\PHPUnit\Framework\MockObject\MockObject
@@ -40,7 +40,7 @@ class AccessAwareRouterTest extends UnitTestCase {
   /**
    * @var \Drupal\Core\Routing\AccessAwareRouter
    */
-  protected $router;
+  protected $accessAwareRouter;
 
   /**
    * {@inheritdoc}
@@ -56,13 +56,13 @@ protected function setUp(): void {
    * Sets up a chain router with matchRequest.
    */
   protected function setupRouter() {
-    $this->chainRouter = $this->getMockBuilder('Symfony\Cmf\Component\Routing\ChainRouter')
+    $this->router = $this->getMockBuilder('Drupal\Core\Routing\Router')
       ->disableOriginalConstructor()
       ->getMock();
-    $this->chainRouter->expects($this->once())
+    $this->router->expects($this->once())
       ->method('matchRequest')
       ->will($this->returnValue([RouteObjectInterface::ROUTE_OBJECT => $this->route]));
-    $this->router = new AccessAwareRouter($this->chainRouter, $this->accessManager, $this->currentUser);
+    $this->accessAwareRouter = new AccessAwareRouter($this->router, $this->accessManager, $this->currentUser);
   }
 
   /**
@@ -76,7 +76,7 @@ public function testMatchRequestAllowed() {
       ->method('checkRequest')
       ->with($request)
       ->willReturn($access_result);
-    $parameters = $this->router->matchRequest($request);
+    $parameters = $this->accessAwareRouter->matchRequest($request);
     $expected = [
       RouteObjectInterface::ROUTE_OBJECT => $this->route,
       AccessAwareRouterInterface::ACCESS_RESULT => $access_result,
@@ -97,7 +97,7 @@ public function testMatchRequestDenied() {
       ->with($request)
       ->willReturn($access_result);
     $this->expectException(AccessDeniedHttpException::class);
-    $this->router->matchRequest($request);
+    $this->accessAwareRouter->matchRequest($request);
   }
 
   /**
@@ -114,7 +114,7 @@ public function testCheckAccessResultWithReason() {
       ->willReturn($access_result);
     $this->expectException(AccessDeniedHttpException::class);
     $this->expectExceptionMessage($reason);
-    $this->router->matchRequest($request);
+    $this->accessAwareRouter->matchRequest($request);
   }
 
   /**
@@ -125,17 +125,17 @@ public function testCheckAccessResultWithReason() {
   public function testCall() {
     $mock_router = $this->createMock('Symfony\Component\Routing\RouterInterface');
 
-    $this->chainRouter = $this->getMockBuilder('Symfony\Cmf\Component\Routing\ChainRouter')
+    $this->router = $this->getMockBuilder('Drupal\Core\Routing\Router')
       ->disableOriginalConstructor()
       ->setMethods(['add'])
       ->getMock();
-    $this->chainRouter->expects($this->once())
+    $this->router->expects($this->once())
       ->method('add')
       ->with($mock_router)
       ->willReturnSelf();
-    $this->router = new AccessAwareRouter($this->chainRouter, $this->accessManager, $this->currentUser);
+    $this->accessAwareRouter = new AccessAwareRouter($this->router, $this->accessManager, $this->currentUser);
 
-    $this->router->add($mock_router);
+    $this->accessAwareRouter->add($mock_router);
   }
 
 }
diff --git a/core/tests/Drupal/Tests/Core/Routing/CurrentRouteMatchTest.php b/core/tests/Drupal/Tests/Core/Routing/CurrentRouteMatchTest.php
index ec3861cf36d2..77ce02405936 100644
--- a/core/tests/Drupal/Tests/Core/Routing/CurrentRouteMatchTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/CurrentRouteMatchTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\Tests\Core\Routing;
 
 use Drupal\Core\Routing\CurrentRouteMatch;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\RequestStack;
diff --git a/core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php b/core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php
new file mode 100644
index 000000000000..88aa9470433d
--- /dev/null
+++ b/core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php
@@ -0,0 +1,94 @@
+<?php
+
+namespace Drupal\Tests\Core\Routing;
+
+use Drupal\Tests\UnitTestCase;
+use Drupal\Core\Routing\LazyRouteCollection;
+use Drupal\Core\Routing\RouteProviderInterface;
+use Symfony\Component\Routing\Exception\RouteNotFoundException;
+use Symfony\Component\Routing\Route;
+
+/**
+ * @coversDefaultClass \Drupal\Core\Routing\LazyRouteCollection
+ *
+ * @group Routing
+ */
+class LazyRouteCollectionTest extends UnitTestCase {
+
+  /**
+   * The route provider.
+   *
+   * @var \Drupal\Core\Routing\RouteProviderInterface
+   */
+  private $routeProvider;
+
+  /**
+   * Array of routes indexed by name.
+   *
+   * @var array
+   */
+  private $testRoutes;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setUp(): void {
+    parent::setUp();
+    $this->routeProvider = $this->createMock(RouteProviderInterface::class);
+    $this->testRoutes = [
+      'route_1' => new Route('/route-1'),
+      'route_2' => new Route('/route-2'),
+    ];
+  }
+
+  /**
+   * @covers ::getIterator
+   * @covers ::all
+   */
+  public function testGetIterator() {
+    $this->routeProvider->expects($this->exactly(2))
+      ->method('getRoutesByNames')
+      ->with(NULL)
+      ->will($this->returnValue($this->testRoutes));
+    $lazyRouteCollection = new LazyRouteCollection($this->routeProvider);
+    $this->assertEquals($this->testRoutes, iterator_to_array($lazyRouteCollection->getIterator()));
+    $this->assertEquals($this->testRoutes, $lazyRouteCollection->all());
+  }
+
+  /**
+   * @covers ::count
+   */
+  public function testCount() {
+    $this->routeProvider
+      ->method('getRoutesByNames')
+      ->with(NULL)
+      ->will($this->returnValue($this->testRoutes));
+    $lazyRouteCollection = new LazyRouteCollection($this->routeProvider);
+    $this->assertEquals(2, $lazyRouteCollection->count());
+  }
+
+  /**
+   * Search for a both an existing and a non-existing route.
+   *
+   * @covers ::get
+   */
+  public function testGetName() {
+    // Hit.
+    $this->routeProvider
+      ->method('getRouteByName')
+      ->with('route_1')
+      ->will($this->returnValue($this->testRoutes['route_1']));
+    $lazyRouteCollection = new LazyRouteCollection($this->routeProvider);
+    $this->assertEquals($lazyRouteCollection->get('route_1'), $this->testRoutes['route_1']);
+
+    // Miss.
+    $this->routeProvider
+      ->method('getRouteByName')
+      ->with('does_not_exist')
+      ->will($this->throwException(new RouteNotFoundException()));
+
+    $lazyRouteCollectionFail = new LazyRouteCollection($this->routeProvider);
+    $this->assertNull($lazyRouteCollectionFail->get('does_not_exist'));
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php
index 0a3c65cbe9fb..a5bfcb33dab7 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\Tests\Core\Routing;
 
 use Drupal\Core\Routing\RouteMatch;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Route;
diff --git a/core/tests/Drupal/Tests/Core/UrlTest.php b/core/tests/Drupal/Tests/Core/UrlTest.php
index 45a869af75f8..99cec218b10a 100644
--- a/core/tests/Drupal/Tests/Core/UrlTest.php
+++ b/core/tests/Drupal/Tests/Core/UrlTest.php
@@ -14,7 +14,7 @@
 use Drupal\Core\Routing\RouteMatch;
 use Drupal\Core\Url;
 use Drupal\Tests\UnitTestCase;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Exception\InvalidParameterException;
-- 
GitLab