Router
extends Router
in package
implements
WarmableInterface, ServiceSubscriberInterface
This Router creates the Loader only when the cache is empty.
Tags
Interfaces, Classes and Traits
- WarmableInterface
- Interface for classes that support warming their cache.
- ServiceSubscriberInterface
- A ServiceSubscriber exposes its dependencies via the static {@link getSubscribedServices} method.
Table of Contents
- $collection : RouteCollection|null
- $context : RequestContext
- $defaultLocale : string|null
- $generator : UrlGeneratorInterface|null
- $loader : LoaderInterface
- $logger : LoggerInterface|null
- $matcher : UrlMatcherInterface|null
- $options : array<string|int, mixed>
- $resource : mixed
- $cache : mixed
- $collectedParameters : mixed
- $configCacheFactory : ConfigCacheFactoryInterface|null
- $container : mixed
- $expressionLanguageProviders : array<string|int, ExpressionFunctionProviderInterface>
- $paramFetcher : mixed
- __construct() : mixed
- addExpressionLanguageProvider() : mixed
- generate() : mixed
- {@inheritdoc}
- getContext() : mixed
- {@inheritdoc}
- getGenerator() : UrlGeneratorInterface
- Gets the UrlGenerator instance associated with this Router.
- getMatcher() : UrlMatcherInterface|RequestMatcherInterface
- Gets the UrlMatcher or RequestMatcher instance associated with this Router.
- getOption() : mixed
- Gets an option value.
- getRouteCollection() : RouteCollection
- Gets the RouteCollection instance associated with this Router.
- getSubscribedServices() : array<string|int, string>
- Returns an array of service types required by such instances, optionally keyed by the service names used internally.
- match() : mixed
- {@inheritdoc}
- matchRequest() : array<string|int, mixed>
- Tries to match a request with a set of routes.
- setConfigCacheFactory() : mixed
- Sets the ConfigCache factory to use.
- setContext() : mixed
- {@inheritdoc}
- setOption() : mixed
- Sets an option.
- setOptions() : mixed
- Sets options.
- warmUp() : array<string|int, string>
- Warms up the cache.
- getGeneratorDumperInstance() : GeneratorDumperInterface
- getMatcherDumperInstance() : MatcherDumperInterface
- getCompiledRoutes() : array<string|int, mixed>
- getConfigCacheFactory() : ConfigCacheFactoryInterface
- Provides the ConfigCache factory implementation, falling back to a default implementation if necessary.
- resolve() : mixed
- Recursively replaces placeholders with the service container parameters.
- resolveParameters() : mixed
- Replaces placeholders with service container parameter values in: - the route defaults, - the route requirements, - the route path, - the route host, - the route schemes, - the route methods.
Properties
$collection
protected
RouteCollection|null
$collection
$context
protected
RequestContext
$context
$defaultLocale
protected
string|null
$defaultLocale
$generator
protected
UrlGeneratorInterface|null
$generator
$loader
protected
LoaderInterface
$loader
$logger
protected
LoggerInterface|null
$logger
$matcher
protected
UrlMatcherInterface|null
$matcher
$options
protected
array<string|int, mixed>
$options
= []
$resource
protected
mixed
$resource
$cache
private
static mixed
$cache
= []
$collectedParameters
private
mixed
$collectedParameters
= []
$configCacheFactory
private
ConfigCacheFactoryInterface|null
$configCacheFactory
$container
private
mixed
$container
$expressionLanguageProviders
private
array<string|int, ExpressionFunctionProviderInterface>
$expressionLanguageProviders
= []
$paramFetcher
private
mixed
$paramFetcher
Methods
__construct()
public
__construct(ContainerInterface $container, mixed $resource[, array<string|int, mixed> $options = [] ][, RequestContext|null $context = null ][, ContainerInterface|null $parameters = null ][, LoggerInterface|null $logger = null ][, string|null $defaultLocale = null ]) : mixed
Parameters
- $container : ContainerInterface
- $resource : mixed
-
The main resource to load
- $options : array<string|int, mixed> = []
- $context : RequestContext|null = null
- $parameters : ContainerInterface|null = null
- $logger : LoggerInterface|null = null
- $defaultLocale : string|null = null
Return values
mixed —addExpressionLanguageProvider()
public
addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) : mixed
Parameters
- $provider : ExpressionFunctionProviderInterface
Return values
mixed —generate()
{@inheritdoc}
public
generate(string $name[, array<string|int, mixed> $parameters = [] ][, int $referenceType = self::ABSOLUTE_PATH ]) : mixed
Parameters
- $name : string
- $parameters : array<string|int, mixed> = []
- $referenceType : int = self::ABSOLUTE_PATH
Return values
mixed —getContext()
{@inheritdoc}
public
getContext() : mixed
Return values
mixed —getGenerator()
Gets the UrlGenerator instance associated with this Router.
public
getGenerator() : UrlGeneratorInterface
Return values
UrlGeneratorInterface —getMatcher()
Gets the UrlMatcher or RequestMatcher instance associated with this Router.
public
getMatcher() : UrlMatcherInterface|RequestMatcherInterface
Return values
UrlMatcherInterface|RequestMatcherInterface —getOption()
Gets an option value.
public
getOption(string $key) : mixed
Parameters
- $key : string
Tags
Return values
mixed —getRouteCollection()
Gets the RouteCollection instance associated with this Router.
public
getRouteCollection() : RouteCollection
Return values
RouteCollection —getSubscribedServices()
Returns an array of service types required by such instances, optionally keyed by the service names used internally.
public
static getSubscribedServices() : array<string|int, string>
Return values
array<string|int, string> —The required service types, optionally keyed by service names
match()
{@inheritdoc}
public
match(string $pathinfo) : mixed
Parameters
- $pathinfo : string
Return values
mixed —matchRequest()
Tries to match a request with a set of routes.
public
matchRequest(Request $request) : array<string|int, mixed>
Parameters
- $request : Request
Return values
array<string|int, mixed> —setConfigCacheFactory()
Sets the ConfigCache factory to use.
public
setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory) : mixed
Parameters
- $configCacheFactory : ConfigCacheFactoryInterface
Return values
mixed —setContext()
{@inheritdoc}
public
setContext(RequestContext $context) : mixed
Parameters
- $context : RequestContext
Return values
mixed —setOption()
Sets an option.
public
setOption(string $key, mixed $value) : mixed
Parameters
- $key : string
- $value : mixed
-
The value
Tags
Return values
mixed —setOptions()
Sets options.
public
setOptions(array<string|int, mixed> $options) : mixed
Available options:
- cache_dir: The cache directory (or null to disable caching)
- debug: Whether to enable debugging or not (false by default)
- generator_class: The name of a UrlGeneratorInterface implementation
- generator_dumper_class: The name of a GeneratorDumperInterface implementation
- matcher_class: The name of a UrlMatcherInterface implementation
- matcher_dumper_class: The name of a MatcherDumperInterface implementation
- resource_type: Type hint for the main resource (optional)
- strict_requirements: Configure strict requirement checking for generators implementing ConfigurableRequirementsInterface (default is true)
Parameters
- $options : array<string|int, mixed>
Tags
Return values
mixed —warmUp()
Warms up the cache.
public
warmUp(string $cacheDir) : array<string|int, string>
Parameters
- $cacheDir : string
Return values
array<string|int, string> —A list of classes to preload on PHP 7.4+
getGeneratorDumperInstance()
protected
getGeneratorDumperInstance() : GeneratorDumperInterface
Return values
GeneratorDumperInterface —getMatcherDumperInstance()
protected
getMatcherDumperInstance() : MatcherDumperInterface
Return values
MatcherDumperInterface —getCompiledRoutes()
private
static getCompiledRoutes(string $path) : array<string|int, mixed>
Parameters
- $path : string
Return values
array<string|int, mixed> —getConfigCacheFactory()
Provides the ConfigCache factory implementation, falling back to a default implementation if necessary.
private
getConfigCacheFactory() : ConfigCacheFactoryInterface
Return values
ConfigCacheFactoryInterface —resolve()
Recursively replaces placeholders with the service container parameters.
private
resolve(mixed $value) : mixed
Parameters
- $value : mixed
-
The source which might contain "%placeholders%"
Tags
Return values
mixed —The source with the placeholders replaced by the container parameters. Arrays are resolved recursively.
resolveParameters()
Replaces placeholders with service container parameter values in: - the route defaults, - the route requirements, - the route path, - the route host, - the route schemes, - the route methods.
private
resolveParameters(RouteCollection $collection) : mixed
Parameters
- $collection : RouteCollection