From 98eed2b1a68abe5300cf5b25ae202f980298f251 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 22 Jun 2020 12:18:44 +0100 Subject: [PATCH] Issue #2917331 by catch, martin107, Deepak Goyal, longwave, andypost, ravi.shankar, 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 | 69 +++++++++++++- .../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, 494 insertions(+), 115 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 e0b7c4f192f..9ffe8e2b7d3 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -27,7 +27,7 @@ use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; 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 b6bc1e1c0bb..d610fdd25c0 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -32,7 +32,7 @@ use Drupal\Core\Extension\ExtensionDiscovery; 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 d2b7e55f99a..36dec5b65c6 100644 --- a/core/lib/Drupal/Core/Access/AccessManager.php +++ b/core/lib/Drupal/Core/Access/AccessManager.php @@ -11,7 +11,7 @@ use Drupal\Core\Session\AccountInterface; 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 f383fbc9864..aa0b41a2fa9 100644 --- a/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php +++ b/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php @@ -4,7 +4,7 @@ namespace Drupal\Core\Entity\Enhancer; 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 9520283a989..18982a6d6e4 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 0f40c5a58eb..67b2fba2b6c 100644 --- a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php @@ -4,7 +4,7 @@ namespace Drupal\Core\EventSubscriber; 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 944bd5304c9..c3ca6ba879e 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 efce47305a2..58976df1775 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\AccessAwareRouterInterface; 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 d54338f4491..bdd52cbdd30 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 c812178d292..9e9df9f71dd 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 aa2b8c830c8..507366bc7c0 100644 --- a/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php +++ b/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php @@ -5,7 +5,7 @@ namespace Drupal\Core\Routing\Enhancer; 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 3ddee667526..3439a4a1720 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 73c9f83a265..ad446a69940 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 00000000000..5f9706efe7f --- /dev/null +++ b/core/lib/Drupal/Core/Routing/LazyRouteCollection.php @@ -0,0 +1,68 @@ +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 10c444758fe..e00be3554f6 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 00000000000..e7afacd6243 --- /dev/null +++ b/core/lib/Drupal/Core/Routing/RouteObjectInterface.php @@ -0,0 +1,29 @@ +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 @@ class RouteProvider implements CacheableRouteProviderInterface, PreloadableRoute } /** - * {@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 @@ class RouteProvider implements CacheableRouteProviderInterface, PreloadableRoute } /** - * {@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 f53593a82e1..2517559f9f8 100644 --- a/core/lib/Drupal/Core/Routing/RouteProviderInterface.php +++ b/core/lib/Drupal/Core/Routing/RouteProviderInterface.php @@ -2,14 +2,79 @@ namespace Drupal\Core\Routing; -use Symfony\Cmf\Component\Routing\RouteProviderInterface as RouteProviderBaseInterface; +use Symfony\Component\HttpFoundation\Request; /** * Extends the router provider interface * * @see \Symfony\Cmf\Component\Routing */ -interface RouteProviderInterface extends RouteProviderBaseInterface { +interface RouteProviderInterface { + + /** + * 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 a2cb8c57851..d5a55a9a3a5 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 @@ class RouteProviderLazyBuilder implements PreloadableRouteProviderInterface, Pag } /** - * {@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 d1586e42b16..8b649a3ec2a 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 @@ use Symfony\Component\Routing\RouterInterface; * 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 e63383df5f8..bbc91de1d19 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 90569033687..bc9a63f5f6e 100644 --- a/core/lib/Drupal/Core/Routing/UrlMatcher.php +++ b/core/lib/Drupal/Core/Routing/UrlMatcher.php @@ -4,8 +4,9 @@ namespace Drupal\Core\Routing; 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 @@ class UrlMatcher extends BaseUrlMatcher { 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 a10af1e48c3..50479750761 100644 --- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php @@ -21,7 +21,7 @@ use Drupal\Tests\SessionTestTrait; 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 2b74dabb67b..edcee199607 100644 --- a/core/lib/Drupal/Core/Update/UpdateKernel.php +++ b/core/lib/Drupal/Core/Update/UpdateKernel.php @@ -6,7 +6,7 @@ use Drupal\Core\DrupalKernel; 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 82c2c600b37..09b988f413e 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -10,7 +10,7 @@ use Drupal\Core\Routing\RouteMatchInterface; 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 c7e51950e8a..dac2ca0d473 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 abc10cff4fc..1b4ef83e436 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\LanguageInterface; 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 50cb8b8c5d7..8da175894ce 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\CacheableBadRequestHttpException; 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 e592f007aef..7ba8338112c 100644 --- a/core/modules/jsonapi/src/Routing/Routes.php +++ b/core/modules/jsonapi/src/Routing/Routes.php @@ -8,7 +8,7 @@ use Drupal\jsonapi\Controller\EntryPoint; 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 6f45d5ecd93..2dcafb191df 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\rest\ResourceResponse; 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 4a70512a0d8..e6c08a65595 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\ResourceTypeRelationship; 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 a28506caebe..87e12c7d4b9 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\Render\BubbleableMetadata; 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 7c973368a39..9695cd57696 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\Entity\ConfigurableLanguage; 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 03669cc3cdf..9e60aa721cd 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\entity_test\Entity\EntityTest; 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 9701bcf8d11..1b9ae65ffe3 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\KernelTests\KernelTestBase; 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 5612ddd75bf..7c34358dec6 100644 --- a/core/modules/system/src/Tests/Routing/MockRouteProvider.php +++ b/core/modules/system/src/Tests/Routing/MockRouteProvider.php @@ -30,7 +30,7 @@ class MockRouteProvider implements RouteProviderInterface { } /** - * 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 fe228a336b6..e8e0604e3ad 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 @@ namespace Drupal\router_test; 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 1c65277f270..0cd5dc479be 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 @@ namespace Drupal\Tests\system\Functional\Theme; 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 6ac0e03d388..b6ea41a1790 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\Core\Render\Element; 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 df5d756801f..0b0c1e4aaad 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\Url; 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 4a829906ae9..fec14c3262b 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\Plugin\ContainerFactoryPluginInterface; 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 26d9ce7e110..2250acf7b37 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 @@ namespace Drupal\Tests\views\Unit\Routing; 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 056c7ea0c35..d1d7387abec 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -16,7 +16,7 @@ use Drupal\Core\Session\AccountInterface; 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 922eefa25b5..457602945c7 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\Cache\Cache; 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 235af6e144f..4da27e3669c 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\Cache\Cache; 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 e21a0ce9c01..41f9ca5ef08 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php @@ -293,6 +293,32 @@ class RouteProviderTest extends KernelTestBase { } } + /** + * 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 @@ class RouteProviderTest extends KernelTestBase { /** * 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 @@ class RouteProviderTest extends KernelTestBase { $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 b1ebad5e32b..5d13f516837 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -28,7 +28,7 @@ use Symfony\Component\DependencyInjection\Reference; 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 4034da8896e..f075dbae0d7 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 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv 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 e1ea9336404..69ede129af7 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\AccessManager; 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 8269796781e..d580d8204e3 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\AuthenticationManager; 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 db481e8c8e0..a250594ee23 100644 --- a/core/tests/Drupal/Tests/Core/Enhancer/EntityRevisionRouteEnhancerTest.php +++ b/core/tests/Drupal/Tests/Core/Enhancer/EntityRevisionRouteEnhancerTest.php @@ -5,7 +5,7 @@ namespace Drupal\Tests\Core\Enhancer; 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 e46b934d10f..148f846cd17 100644 --- a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php +++ b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php @@ -4,7 +4,7 @@ namespace Drupal\Tests\Core\Enhancer; 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 8eed80ac0d1..297628262cc 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 @@ namespace Drupal\Tests\Core\Entity\Enhancer; 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 ee158c84242..6a2e7b6fd79 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php @@ -4,7 +4,7 @@ namespace Drupal\Tests\Core\EventSubscriber; 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 0aa466bddc4..16b18a76636 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\EventSubscriber\SpecialAttributesRouteSubscriber; 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 4b8e8134f90..cf0483cc5d1 100644 --- a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php @@ -5,7 +5,7 @@ namespace Drupal\Tests\Core\Menu; 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 7c0feba2fe6..d755a783953 100644 --- a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php +++ b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php @@ -5,7 +5,7 @@ namespace Drupal\Tests\Core\ParamConverter; 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 d595193eb69..ae94ab15e2f 100644 --- a/core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php +++ b/core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php @@ -5,7 +5,7 @@ namespace Drupal\Tests\Core\Path; 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 a52f9735a37..1908fbe0317 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\Access\AccessResult; 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 @@ class AccessAwareRouterTest extends UnitTestCase { * 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 @@ class AccessAwareRouterTest extends UnitTestCase { ->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 @@ class AccessAwareRouterTest extends UnitTestCase { ->with($request) ->willReturn($access_result); $this->expectException(AccessDeniedHttpException::class); - $this->router->matchRequest($request); + $this->accessAwareRouter->matchRequest($request); } /** @@ -114,7 +114,7 @@ class AccessAwareRouterTest extends UnitTestCase { ->willReturn($access_result); $this->expectException(AccessDeniedHttpException::class); $this->expectExceptionMessage($reason); - $this->router->matchRequest($request); + $this->accessAwareRouter->matchRequest($request); } /** @@ -125,17 +125,17 @@ class AccessAwareRouterTest extends UnitTestCase { 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 ec3861cf36d..77ce0240593 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 00000000000..88aa9470433 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php @@ -0,0 +1,94 @@ +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 0a3c65cbe9f..a5bfcb33dab 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 45a869af75f..99cec218b10 100644 --- a/core/tests/Drupal/Tests/Core/UrlTest.php +++ b/core/tests/Drupal/Tests/Core/UrlTest.php @@ -14,7 +14,7 @@ use Drupal\Core\GeneratedUrl; 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;