Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CompiledUrlMatcherDumper.php

function CompiledUrlMatcherDumper::compileRoute

Compiles a single Route to PHP code used to match it against the path info.

2 calls to CompiledUrlMatcherDumper::compileRoute()
CompiledUrlMatcherDumper::compileStaticPrefixCollection in vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherDumper.php
Compiles a regexp tree of subpatterns that matches nested same-prefix routes.
CompiledUrlMatcherDumper::compileStaticRoutes in vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherDumper.php
Compiles static routes in a switch statement.

File

vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherDumper.php, line 416

Class

CompiledUrlMatcherDumper
CompiledUrlMatcherDumper creates PHP arrays to be used with CompiledUrlMatcher.

Namespace

Symfony\Component\Routing\Matcher\Dumper

Code

private function compileRoute(Route $route, string $name, string|array|null $vars, bool $hasTrailingSlash, bool $hasTrailingVar, array &$conditions) : array {
    $defaults = $route->getDefaults();
    if (isset($defaults['_canonical_route'])) {
        $name = $defaults['_canonical_route'];
        unset($defaults['_canonical_route']);
    }
    if ($condition = $route->getCondition()) {
        $condition = $this->getExpressionLanguage()
            ->compile($condition, [
            'context',
            'request',
            'params',
        ]);
        $condition = $conditions[$condition] ??= (str_contains($condition, '$request') ? 1 : -1) * \count($conditions);
    }
    else {
        $condition = null;
    }
    return [
        [
            '_route' => $name,
        ] + $defaults,
        $vars,
        array_flip($route->getMethods()) ?: null,
        array_flip($route->getSchemes()) ?: null,
        $hasTrailingSlash,
        $hasTrailingVar,
        $condition,
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal