Drupal 8  8.0.2
RouteProvider Class Reference
Inheritance diagram for RouteProvider:

Public Member Functions

 __construct (Connection $connection, StateInterface $state, CurrentPathStack $current_path, CacheBackendInterface $cache_backend, InboundPathProcessorInterface $path_processor, CacheTagsInvalidatorInterface $cache_tag_invalidator, $table= 'router')
 
 getRouteCollectionForRequest (Request $request)
 
 getRouteByName ($name)
 
 preLoadRoutes ($names)
 
 getRoutesByNames ($names)
 
 getRoutesByPattern ($pattern)
 
 getAllRoutes ()
 
 reset ()
 
 getRoutesPaged ($offset, $length=NULL)
 
 getRoutesCount ()
 

Static Public Member Functions

static getSubscribedEvents ()
 

Data Fields

const ROUTE_LOAD_CID_PREFIX = 'route_provider.route_load:'
 

Protected Member Functions

 getCandidateOutlines (array $parts)
 
 getRoutesByPath ($path)
 
 routeProviderRouteCompare (array $a, array $b)
 

Protected Attributes

 $connection
 
 $tableName
 
 $state
 
 $routes = array()
 
 $serializedRoutes = []
 
 $currentPath
 
 $cache
 
 $cacheTagInvalidator
 
 $pathProcessor
 

Detailed Description

A Route Provider front-end for all Drupal-stored routes.

Constructor & Destructor Documentation

__construct ( Connection  $connection,
StateInterface  $state,
CurrentPathStack  $current_path,
CacheBackendInterface  $cache_backend,
InboundPathProcessorInterface  $path_processor,
CacheTagsInvalidatorInterface  $cache_tag_invalidator,
  $table = 'router' 
)

Constructs a new PathMatcher.

Parameters
\Drupal\Core\Database\Connection$connectionA database connection object.
\Drupal\Core\State\StateInterface$stateThe state.
\Drupal\Core\Path\CurrentPathStack$current_pathThe current path.
\Drupal\Core\Cache\CacheBackendInterface$cache_backendThe cache backend.
\Drupal\Core\PathProcessor\InboundPathProcessorInterface$path_processorThe path processor.
\Drupal\Core\Cache\CacheTagsInvalidatorInterface$cache_tag_invalidatorThe cache tag invalidator.
string$table(Optional) The table in the database to use for matching. Defaults to 'router'

References Drupal\cache(), and Drupal\state().

Here is the call graph for this function:

Member Function Documentation

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.

Returns
[] An iterator of routes keyed by route name.
}

Implements RouteProviderInterface.

getCandidateOutlines ( array  $parts)
protected

Returns an array of path pattern outlines that could match the path parts.

Parameters
array$partsThe parts of the path for which we want candidates.
Returns
array An array of outlines that could match the specified path parts.

References Drupal\state().

Referenced by RouteProvider\getRoutesByPath().

Here is the call graph for this function:

Here is the caller graph for this function:

getRouteByName (   $name)

Find the route using the provided route name (and parameters).

Parameters
string$nameThe route name to fetch
Returns
The found route.
Exceptions
\Symfony\Component\Routing\Exception\RouteNotFoundExceptionThrown if there is no route with that name in this repository.

References RouteProvider\getRoutesByNames(), and RouteProvider\reset().

Here is the call graph for this function:

getRouteCollectionForRequest ( Request  $request)

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.

Parameters
Request$requestA request against which to match.
Returns
with all urls that could potentially match $request. Empty collection if nothing can match.

References Drupal\cache(), CacheBackendInterface\CACHE_PERMANENT, and RouteProvider\getRoutesByPath().

Here is the call graph for this function:

getRoutesByNames (   $names)

{}

References RouteProvider\preLoadRoutes().

Referenced by RouteProvider\getRouteByName().

Here is the call graph for this function:

Here is the caller graph for this function:

getRoutesByPath (   $path)
protected

Get all routes which match a certain pattern.

Parameters
string$pathThe route pattern to search for (contains % as placeholders).
Returns
Returns a route collection of matching routes.

References RouteProvider\getCandidateOutlines().

Referenced by RouteProvider\getRouteCollectionForRequest(), and RouteProvider\getRoutesByPattern().

Here is the call graph for this function:

Here is the caller graph for this function:

getRoutesByPattern (   $pattern)

{Get all routes which match a certain pattern.

Parameters
string$patternThe route pattern to search for (contains {} as placeholders).
Returns
Returns a route collection of matching routes.
}

Implements RouteProviderInterface.

References RouteCompiler\getPatternOutline(), and RouteProvider\getRoutesByPath().

Here is the call graph for this function:

getRoutesCount ( )

{}

getRoutesPaged (   $offset,
  $length = NULL 
)

{}

static getSubscribedEvents ( )
static

{}

preLoadRoutes (   $names)

{Pre-load routes by their names using the provided list of names.This method exists in order to allow performance optimizations. It allows pre-loading serialized routes that may latter be retrieved using ::getRoutesByName()

Parameters
string[]$names Array of route names to load.
}

Implements PreloadableRouteProviderInterface.

References Drupal\cache(), and Cache\PERMANENT.

Referenced by RouteProvider\getRoutesByNames().

Here is the call graph for this function:

Here is the caller graph for this function:

reset ( )

{Resets the route provider object.}

Implements RouteProviderInterface.

Referenced by RouteProvider\getRouteByName().

Here is the caller graph for this function:

routeProviderRouteCompare ( array  $a,
array  $b 
)
protected

Comparison function for usort on routes.

Field Documentation

const ROUTE_LOAD_CID_PREFIX = 'route_provider.route_load:'

Cache ID prefix used to load routes.


The documentation for this class was generated from the following file: