CustomRouteCompiler
extends RouteCompiler
in package
RouteCompiler compiles Route instances to CompiledRoute instances.
Table of Contents
- REGEX_DELIMITER = '#'
- SEPARATORS = '/,;.:-_~+*=@|'
- This string defines the characters that are automatically considered separators in front of optional placeholders (with default and no static text following). Such a single separator can be left out together with the optional placeholder from matching and generating URLs.
- compile() : CompiledRoute
- Compiles the current route instance.
- compilePattern() : mixed
- computeRegexp() : string
- Computes the regexp used to match a specific token. It can be static text or a subpattern.
- determineStaticPrefix() : string
- Determines the longest static prefix possible for a route.
- findNextSeparator() : string
- Returns the next static character in the Route pattern that will serve as a separator.
Constants
REGEX_DELIMITER
public
mixed
REGEX_DELIMITER
= '#'
SEPARATORS
This string defines the characters that are automatically considered separators in front of optional placeholders (with default and no static text following). Such a single separator can be left out together with the optional placeholder from matching and generating URLs.
public
mixed
SEPARATORS
= '/,;.:-_~+*=@|'
Methods
compile()
Compiles the current route instance.
public
static compile(Route $route) : CompiledRoute
Parameters
- $route : Route
Return values
CompiledRoute —A CompiledRoute instance
compilePattern()
private
static compilePattern(Route $route, mixed $pattern, mixed $isHost) : mixed
Parameters
- $route : Route
- $pattern : mixed
- $isHost : mixed
Return values
mixed —computeRegexp()
Computes the regexp used to match a specific token. It can be static text or a subpattern.
private
static computeRegexp(array<string|int, mixed> $tokens, int $index, int $firstOptional) : string
Parameters
- $tokens : array<string|int, mixed>
-
The route tokens
- $index : int
-
The index of the current token
- $firstOptional : int
-
The index of the first optional token
Return values
string —The regexp pattern for a single token
determineStaticPrefix()
Determines the longest static prefix possible for a route.
private
static determineStaticPrefix(Route $route, array<string|int, mixed> $tokens) : string
Parameters
- $route : Route
- $tokens : array<string|int, mixed>
Return values
string —The leading static part of a route's path
findNextSeparator()
Returns the next static character in the Route pattern that will serve as a separator.
private
static findNextSeparator(string $pattern, bool $useUtf8) : string
Parameters
- $pattern : string
-
The route pattern
- $useUtf8 : bool
-
Whether the character is encoded in UTF-8 or not
Return values
string —The next static character that functions as separator (or empty string when none available)