PhpMatcherDumper
extends MatcherDumper
in package
PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes.
Tags
Table of Contents
- $expressionLanguage : mixed
- $expressionLanguageProviders : array<string|int, ExpressionFunctionProviderInterface>
- $routes : mixed
- __construct() : mixed
- addExpressionLanguageProvider() : mixed
- dump() : string
- Dumps a set of routes to a PHP class.
- getRoutes() : RouteCollection
- Gets the routes to dump.
- buildStaticPrefixCollection() : mixed
- compileRoute() : string
- Compiles a single Route to PHP code used to match it against the path info.
- compileRoutes() : string
- Generates PHP code to match a RouteCollection with all its routes.
- compileStaticPrefixRoutes() : string
- Generates PHP code to match a tree of routes.
- generateMatchMethod() : string
- Generates the code for the match method implementing UrlMatcherInterface.
- getExpressionLanguage() : mixed
- groupRoutesByHostRegex() : DumperCollection
- Groups consecutive routes having the same host regex.
Properties
$expressionLanguage
private
mixed
$expressionLanguage
$expressionLanguageProviders
private
array<string|int, ExpressionFunctionProviderInterface>
$expressionLanguageProviders
= []
$routes
private
mixed
$routes
Methods
__construct()
public
__construct(RouteCollection $routes) : mixed
Parameters
- $routes : RouteCollection
Return values
mixed —addExpressionLanguageProvider()
public
addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) : mixed
Parameters
- $provider : ExpressionFunctionProviderInterface
Return values
mixed —dump()
Dumps a set of routes to a PHP class.
public
dump([array<string|int, mixed> $options = [] ]) : string
Available options:
- class: The class name
- base_class: The base class name
Parameters
- $options : array<string|int, mixed> = []
-
An array of options
Return values
string —A PHP class representing the matcher class
getRoutes()
Gets the routes to dump.
public
getRoutes() : RouteCollection
Return values
RouteCollection —A RouteCollection instance
buildStaticPrefixCollection()
private
buildStaticPrefixCollection(DumperCollection $collection) : mixed
Parameters
- $collection : DumperCollection
Return values
mixed —compileRoute()
Compiles a single Route to PHP code used to match it against the path info.
private
compileRoute(Route $route, string $name, bool $supportsRedirections[, string|null $parentPrefix = null ]) : string
Parameters
- $route : Route
-
A Route instance
- $name : string
-
The name of the Route
- $supportsRedirections : bool
-
Whether redirections are supported by the base class
- $parentPrefix : string|null = null
-
The prefix of the parent collection used to optimize the code
Tags
Return values
string —PHP code
compileRoutes()
Generates PHP code to match a RouteCollection with all its routes.
private
compileRoutes(RouteCollection $routes, bool $supportsRedirections) : string
Parameters
- $routes : RouteCollection
-
A RouteCollection instance
- $supportsRedirections : bool
-
Whether redirections are supported by the base class
Return values
string —PHP code
compileStaticPrefixRoutes()
Generates PHP code to match a tree of routes.
private
compileStaticPrefixRoutes(StaticPrefixCollection $collection, bool $supportsRedirections[, string $ifOrElseIf = 'if' ]) : string
Parameters
- $collection : StaticPrefixCollection
-
A StaticPrefixCollection instance
- $supportsRedirections : bool
-
Whether redirections are supported by the base class
- $ifOrElseIf : string = 'if'
-
either "if" or "elseif" to influence chaining
Return values
string —PHP code
generateMatchMethod()
Generates the code for the match method implementing UrlMatcherInterface.
private
generateMatchMethod(bool $supportsRedirections) : string
Parameters
- $supportsRedirections : bool
-
Whether redirections are supported by the base class
Return values
string —Match method as PHP code
getExpressionLanguage()
private
getExpressionLanguage() : mixed
Return values
mixed —groupRoutesByHostRegex()
Groups consecutive routes having the same host regex.
private
groupRoutesByHostRegex(RouteCollection $routes) : DumperCollection
The result is a collection of collections of routes having the same host regex.
Parameters
- $routes : RouteCollection
-
A flat RouteCollection
Return values
DumperCollection —A collection with routes grouped by host regex in sub-collections