Issue #2917331 by catch, martin107, Deepak Goyal, longwave, andypost, ravi.shankar, daffie, larowlan: Decouple from Symfony CMF

merge-requests/2/head
Alex Pott 2020-06-22 12:18:44 +01:00
parent e685313296
commit 98eed2b1a6
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
63 changed files with 494 additions and 115 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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.

View File

@ -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;
/**

View File

@ -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) {

View File

@ -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;
/**

View File

@ -2,7 +2,7 @@
namespace Drupal\Core\ParamConverter;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Drupal\Core\Routing\RouteObjectInterface;
use Symfony\Component\Routing\RouteCollection;
/**

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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';
}

View File

@ -10,8 +10,6 @@ use Drupal\Core\Language\LanguageManagerInterface;
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 @@ use Drupal\Core\Database\Connection;
/**
* 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 @@ class RouteProvider implements CacheableRouteProviderInterface, PreloadableRoute
* {@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 @@ 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();
}

View File

@ -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.

View File

@ -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();
}

View File

@ -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;

View File

@ -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.

View File

@ -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());
}
}

View File

@ -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;
/**

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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;
/**

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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'));
}
}

View File

@ -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;

View File

@ -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;