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

Breadcrumb

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

function CompiledUrlGeneratorDumper::getCompiledAliases

1 call to CompiledUrlGeneratorDumper::getCompiledAliases()
CompiledUrlGeneratorDumper::generateDeclaredRoutes in vendor/symfony/routing/Generator/Dumper/CompiledUrlGeneratorDumper.php
Generates PHP code representing an array of defined routes together with the routes properties (e.g. requirements).

File

vendor/symfony/routing/Generator/Dumper/CompiledUrlGeneratorDumper.php, line 47

Class

CompiledUrlGeneratorDumper
CompiledUrlGeneratorDumper creates a PHP array to be used with CompiledUrlGenerator.

Namespace

Symfony\Component\Routing\Generator\Dumper

Code

public function getCompiledAliases() : array {
    $routes = $this->getRoutes();
    $compiledAliases = [];
    foreach ($routes->getAliases() as $name => $alias) {
        $deprecations = $alias->isDeprecated() ? [
            $alias->getDeprecation($name),
        ] : [];
        $currentId = $alias->getId();
        $visited = [];
        while (null !== ($alias = $routes->getAlias($currentId) ?? null)) {
            if (false !== ($searchKey = array_search($currentId, $visited))) {
                $visited[] = $currentId;
                throw new RouteCircularReferenceException($currentId, \array_slice($visited, $searchKey));
            }
            if ($alias->isDeprecated()) {
                $deprecations[] = $deprecation = $alias->getDeprecation($currentId);
                trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']);
            }
            $visited[] = $currentId;
            $currentId = $alias->getId();
        }
        if (null === ($target = $routes->get($currentId))) {
            throw new RouteNotFoundException(\sprintf('Target route "%s" for alias "%s" does not exist.', $currentId, $name));
        }
        $compiledTarget = $target->compile();
        $compiledAliases[$name] = [
            $compiledTarget->getVariables(),
            $target->getDefaults(),
            $target->getRequirements(),
            $compiledTarget->getTokens(),
            $compiledTarget->getHostTokens(),
            $target->getSchemes(),
            $deprecations,
        ];
    }
    return $compiledAliases;
}

API Navigation

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