public function RouteCompiler::compile

Same name in this branch
  1. 9.x drupal/core/lib/Drupal/Core/Routing/RouteCompiler.php \Drupal\Core\Routing\RouteCompiler::compile()
  2. 9.x drupal/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php \Symfony\Component\Routing\RouteCompiler::compile()

Compiles the current route instance.

Parameters

\Symfony\Component\Routing\Route $route: A Route instance.

Return value

\Drupal\Core\Routing\CompiledRoute A CompiledRoute instance.

Overrides RouteCompilerInterface::compile

File

drupal/core/lib/Drupal/Core/Routing/RouteCompiler.php, line 37
Definition of Drupal\Core\Routing\RouteCompiler.

Class

RouteCompiler
Compiler to generate derived information from a Route necessary for matching.

Namespace

Drupal\Core\Routing

Code

public function compile(Route $route) {
  $stripped_path = $this
    ->getPathWithoutDefaults($route);
  $fit = $this
    ->getFit($stripped_path);
  $pattern_outline = $this
    ->getPatternOutline($stripped_path);
  $num_parts = count(explode('/', trim($pattern_outline, '/')));
  $regex = $this
    ->getRegex($route, $route
    ->getPattern());
  return new CompiledRoute($route, $fit, $pattern_outline, $num_parts, $regex);
}