class MockRouteProvider implements RouteProviderInterface (View source)

Easily configurable mock route provider.

Properties

protected RouteCollection $routes

A collection of routes for this route provider.

Methods

__construct(RouteCollection $routes)

Constructs a new MockRouteProvider.

getRouteCollectionForRequest(Request $request)

Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRouteCollectionForRequest().

getRouteByName($name)

{@inheritdoc}

preLoadRoutes($names)

{@inheritdoc}

getRoutesByNames($names)

{@inheritdoc}

RouteCollection
getRoutesByPattern(string $pattern)

Get all routes which match a certain pattern.

Route[]
getAllRoutes()

Returns all the routes on the system.

reset()

Resets the route provider object.

Details

__construct(RouteCollection $routes)

Constructs a new MockRouteProvider.

Parameters

RouteCollection $routes

The route collection to use for this provider.

getRouteCollectionForRequest(Request $request)

Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRouteCollectionForRequest().

Simply return all routes to prevent \Symfony\Component\Routing\Exception\ResourceNotFoundException.

Parameters

Request $request

getRouteByName($name)

{@inheritdoc}

Parameters

$name

preLoadRoutes($names)

{@inheritdoc}

Parameters

$names

getRoutesByNames($names)

{@inheritdoc}

Parameters

$names

RouteCollection getRoutesByPattern(string $pattern)

Get all routes which match a certain pattern.

Parameters

string $pattern

The route pattern to search for (contains } as placeholders).

Return Value

RouteCollection

Returns a route collection of matching routes. The collection may be empty and will be sorted from highest to lowest fit (match of path parts) and then in ascending order by route name for routes with the same fit.

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.

Return Value

Route[]

An iterator of routes keyed by route name.

reset()

Resets the route provider object.