diff --git a/core/lib/Drupal/Core/Routing/CompiledRoute.php b/core/lib/Drupal/Core/Routing/CompiledRoute.php index 58498ce455..7a59799db9 100644 --- a/core/lib/Drupal/Core/Routing/CompiledRoute.php +++ b/core/lib/Drupal/Core/Routing/CompiledRoute.php @@ -3,12 +3,20 @@ namespace Drupal\Core\Routing; use Symfony\Component\Routing\CompiledRoute as SymfonyCompiledRoute; +use Symfony\Component\Routing\Route; /** * A compiled route contains derived information from a route object. */ class CompiledRoute extends SymfonyCompiledRoute { + /** + * A Route instance. + * + * @var \Symfony\Component\Routing\Route + */ + protected $route; + /** * The fitness of this route. * @@ -38,6 +46,8 @@ class CompiledRoute extends SymfonyCompiledRoute { * problem. The parent Symfony class does the same, as well, making it * difficult to override differently. * + * @param \Symfony\Component\Routing\Route $route + * A Route instance. * @param int $fit * The fitness of the route. * @param string $pattern_outline @@ -61,9 +71,10 @@ class CompiledRoute extends SymfonyCompiledRoute { * @param array $variables * An array of variables (variables defined in the path and in the host patterns) */ - public function __construct($fit, $pattern_outline, $num_parts, $staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = NULL, array $hostTokens = [], array $hostVariables = [], array $variables = []) { + public function __construct(Route $route, $fit, $pattern_outline, $num_parts, $staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = NULL, array $hostTokens = [], array $hostVariables = [], array $variables = []) { parent::__construct($staticPrefix, $regex, $tokens, $pathVariables, $hostRegex, $hostTokens, $hostVariables, $variables); + $this->route = $route; $this->fit = $fit; // Support case-insensitive route matching by ensuring the pattern outline // is lowercase. diff --git a/core/lib/Drupal/Core/Routing/RouteCompiler.php b/core/lib/Drupal/Core/Routing/RouteCompiler.php index da890c0152..435d27c7dc 100644 --- a/core/lib/Drupal/Core/Routing/RouteCompiler.php +++ b/core/lib/Drupal/Core/Routing/RouteCompiler.php @@ -45,6 +45,7 @@ public static function compile(Route $route) { $num_parts = count(explode('/', trim($route->getPath(), '/'))); return new CompiledRoute( + $route, $fit, $pattern_outline, $num_parts, diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php index 0bce9a3369..d6a919686b 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php @@ -59,6 +59,7 @@ public function testCompilation() { $this->assertEquals($compiled->getFit(), 5 /* That's 101 binary*/, 'The fit was incorrect.'); $this->assertEquals($compiled->getPatternOutline(), '/test/%/more', 'The pattern outline was not correct.'); + $this->assertArrayHasKey('compiler_class', $compiled->getOptions()); } /**