MockRouteProvider
class MockRouteProvider implements RouteProviderInterface (View source)
Easily configurable mock route provider.
Properties
| protected RouteCollection | $routes | A collection of routes for this route provider. |
Methods
Constructs a new MockRouteProvider.
Implements \Drupal\Core\Routing\RouteProviderInterface::getRouteCollectionForRequest().
Find the route using the provided route name.
{@inheritdoc}
Find many routes by their names using the provided list of names.
Get all routes which match a certain pattern.
Returns all the routes on the system.
Resets the route provider object.
Details
__construct(RouteCollection $routes)
Constructs a new MockRouteProvider.
RouteCollection
getRouteCollectionForRequest(Request $request)
Implements \Drupal\Core\Routing\RouteProviderInterface::getRouteCollectionForRequest().
Simply return all routes to prevent \Symfony\Component\Routing\Exception\ResourceNotFoundException.
Route
getRouteByName(string $name)
Find the route using the provided route name.
preLoadRoutes($names)
{@inheritdoc}
Route[]
getRoutesByNames(array|null $names)
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.
RouteCollection
getRoutesByPattern(string $pattern)
Get all routes which match a certain pattern.
Route[]
getAllRoutes()
Returns all the routes on the system.
Usage of this method is discouraged for performance reasons. If possible, use RouteProviderInterface::getRoutesByNames() or RouteProviderInterface::getRoutesByPattern() instead.
reset()
Resets the route provider object.