RouteCompiler
class RouteCompiler extends RouteCompiler implements RouteCompilerInterface (View source)
Compiler to generate derived information from a Route necessary for matching.
Methods
Compiles the current route instance.
Returns the pattern outline.
Determines the fitness of the provided path.
Returns the path of the route, without placeholders with a default value.
Details
static CompiledRoute
compile(Route $route)
Compiles the current route instance.
Because so much of the parent class is private, we need to call the parent class's compile() method and then dissect its return value to build our new compiled object. If upstream gets refactored so we can subclass more easily then this may not be necessary.
static string
getPatternOutline(string $path)
Returns the pattern outline.
The pattern outline is the path pattern but normalized so that all placeholders are the string '%'.
static int
getFit(string $path)
Determines the fitness of the provided path.
static string
getPathWithoutDefaults(Route $route)
Returns the path of the route, without placeholders with a default value.
When computing the path outline and fit, we want to skip default-value placeholders. If we didn't, the path would never match. Note that this only works for placeholders at the end of the path. Infix placeholders with default values don't make sense anyway, so that should not be a problem.