RouteCircularReferenceException example


        $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();
            }

            
/** * Gets a route by name. */
    public function get(string $name): ?Route
    {
        $visited = [];
        while (null !== $alias = $this->aliases[$name] ?? null) {
            if (false !== $searchKey = array_search($name$visited)) {
                $visited[] = $name;

                throw new RouteCircularReferenceException($name, \array_slice($visited$searchKey));
            }

            if ($alias->isDeprecated()) {
                $deprecation = $alias->getDeprecation($name);

                trigger_deprecation($deprecation['package']$deprecation['version']$deprecation['message']);
            }

            $visited[] = $name;
            $name = $alias->getId();
        }

        
/** * Gets a route by name. */
    public function get(string $name): ?Route
    {
        $visited = [];
        while (null !== $alias = $this->aliases[$name] ?? null) {
            if (false !== $searchKey = array_search($name$visited)) {
                $visited[] = $name;

                throw new RouteCircularReferenceException($name, \array_slice($visited$searchKey));
            }

            if ($alias->isDeprecated()) {
                $deprecation = $alias->getDeprecation($name);

                trigger_deprecation($deprecation['package']$deprecation['version']$deprecation['message']);
            }

            $visited[] = $name;
            $name = $alias->getId();
        }

        

        $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();
            }

            
Home | Imprint | This part of the site doesn't use cookies.