Makes field auto completable
@param array $route auto complete route
@return static the field object itself
966333
public function autoComplete($route)
    {
        static $counter = 0;

        $this->inputOptions['class'] .= ' typeahead typeahead-' . (++$counter);

        $data['remote'] = Url::toRoute($route) . '?q=%QUERY';

        $this->form->getView()->registerJs("yii.qa.fieldAutocomplete($counter, " . Json::encode($data) . ");");

        return $this;
    }
1342711
public function add(Route $route): self
    {
        if ($route->uri === ""
            || $route->method === 0b0
            || $route->action === null) {
            $this->logger->error("Route incomplete. Unable to add");
            $this->logger->debug("Incomplete Route", [$route]);
            throw new Exception\RouteIncompleteException(
                "Retrieved Route is not complete and can not be stored"
            );
        }

        // store default route
        if ($route->isDefault) {
            if ($this->defaultRoute === null) {
                $this->defaultRoute = $route;
            } else {
                $this->logger->debug(
                    "Default route already added to container, skipping add.",
                    ["route" => $route, "storedDefault" => $this->defaultRoute]
                );
            }
        }

        // store 404 route
        if ($route->is404) {
            if ($this->e404Route === null) {
                $this->e404Route = $route;
                $this->logger->info("404 route added to Route Container");
            } else {
                $this->logger->debug(
                    "404 route already added to container, skipping add.",
                    ["route" => $route, "stored404" => $this->e404Route]
                );
            }

            return $this;
        }

        // store route to regular container
        $this->routes[] = $route;

        $this->logger->info(
            "Route successfully added to Container",
            ["uri" => $route->uri]
        );

        return $this;
    }
1158096
private function createContentForInternalRoute($route)
    {
        // Load index and map route to content
        $this->load("index");
        $this->load("meta");
        $this->load("author");
        $this->load("category");
        
        // Match the route
        $route = rtrim($route, "/");
        $route = $this->checkForMetaRoute($route);
        list($routeIndex, $content, $filtered) = $this->mapRoute2Content($route);

        // Create and arrange the content as views, merge with .meta,
        // frontmatter is complete.
        $content["views"] = $this->getViews($routeIndex, $filtered->frontmatter);

        // Do process content step two when all frontmatter is included.
        $this->processMainContentPhaseTwo($content, $filtered);
        
        // Set details of content
        $content["views"]["main"]["data"]["content"] = $filtered->text;
        $content["views"]["main"]["data"]["excerpt"] = $filtered->excerpt;
        $this->loadAdditionalContent($content["views"], $route, $routeIndex);

        // TODO Should not supply all frontmatter to theme, only the
        // parts valid to the index template. Separate that data into own
        // holder in frontmatter. Do not include whole frontmatter? Only
        // on debg?
        $content["frontmatter"] = $filtered->frontmatter;

        return (object) $content;
    }
12880
protected function compileRoute(Route $route): array
    {
        $regex = '';
        $prefix = '';
        $prio = 0;
        $pre = true;
        
        $wildcard = false;
        
        foreach (\explode('/', $route->pattern) as $level => $entry) {
            if (!$level) {
                continue;
            }
            
            if ($wildcard) {
                throw new \RuntimeException('No additional path segments are allowed after wildcard matcher');
            }
            
            if ($pre) {
                $prefix .= '/';
            } else {
                $regex .= '/';
            }
            
            $prio += 1000;
            
            if (false === \strpos($entry, '{')) {
                if ($pre) {
                    $prefix .= $entry;
                } else {
                    $regex .= \preg_quote($entry, "'");
                }
                
                $prio += 2;
                
                continue;
            }
            
            $pre = false;
            
            $parts = \preg_split("'(\\{[^\\}]+\\})'", $entry, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
            $boost = 0;
            
            foreach ($parts as $part) {
                if ($part[0] != '{') {
                    $regex .= \preg_quote($part, "'");
                    $boost += 2;
                    
                    continue;
                }
                
                if (\substr($part, -2) == '*}') {
                    $regex .= '(.+)';
                    $wildcard = true;
                    
                    break;
                }
                
                $regex .= '([^/]+)';
                $boost -= 1;
            }
            
            if ($wildcard) {
                if (\count($parts) !== 1) {
                    throw new \RuntimeException('Wildcard patern must be the only placeholder of the last route level');
                }
                
                $prio -= 500;
            } else {
                $prio += $boost;
            }
        }
        
        return [
            $route,
            $prio,
            '/' . \ltrim($prefix, '/'),
            $regex
        ];
    }
137571
public function finalize() : Route
    {
        if ($this->finalized) {
            return $this;
        }

        foreach ($this->getGroups() as $group) {
            foreach ($group->getMiddleware() as $middleware) {
                $this->addMiddleware($middleware);
            }
        }

        $this->finalized = true;

        return $this;
    }
587646
public function add(Route $route)
    {
        $this->addToCollections($route);

        $this->addLookups($route);

        return $route;
    }
63229
public function addRoutes(array $routes)
    {
        foreach ($routes as $name => $route) {
            $this->addRoute($name, $route);
        }
        return $this;
    }
1230709
public function activateOnRoute(string $route)
    {
        $this->activeWhen = function () use ($route) {
            return str_contains(Route::currentRouteName(), $route);
        };

        return $this;
    }
1175175
public function member($route)
    {
        $resource = new self;
        $resource->set($route);
        $this->nest($resource);
    }
870592
public function set($route)
    {
        if ($route instanceof Group) {
            foreach ($route->all() as $r)
                $this->routes[] = $r;
        } else  $this->routes[] = $route;
        return  $this;
    }
404852
protected function getRouteRequirementParams(array $route)
    {
        $params = [];
        if (isset($route['requirements'])) {
            foreach ($route['requirements'] as $fieldName => $requirement) {
                if ('\d{4}-\d{2}-\d{2}' === $requirement) {
                    // Special case, if we need to have a date
                    $params[$fieldName] = substr($this->get($fieldName), 0, 10);
                } elseif ($this->getTaxonomy() !== null && !$this->getTaxonomy()->getField($fieldName)->isEmpty()) {
                    // This is for new storage handling of taxonomies in
                    // contentroutes. If in legacy it will fall back to the one
                    // below.
                    $params[$fieldName] = $this->getTaxonomy()->getField($fieldName)->first()->getSlug();
                } elseif (isset($this->taxonomy[$fieldName])) {
                    // Turn something like '/groups/meta' to 'meta'. This is
                    // only for legacy storage.
                    $tempKeys = array_keys($this->taxonomy[$fieldName]);
                    $tempValues = explode('/', array_shift($tempKeys));
                    $params[$fieldName] = array_pop($tempValues);
                } elseif ($this->get($fieldName)) {
                    $params[$fieldName] = $this->get($fieldName);
                } elseif (isset($route['defaults'][$fieldName])) {
                    $params[$fieldName] = $route['defaults'][$fieldName];
                } else {
                    // unknown
                    $params[$fieldName] = null;
                }
            }
        }

        return $params;
    }
605441
public function addRoute(Route $route)
	{
		foreach ($route->getMethods() as $method)
		{
			$this->routes[$method][/*$route->uri*/] = $route;
		}
		
		$this->allRoutes[] = $route;

		return $this;
	}
97482
public function gatherRouteMiddlewares(Route $route)
    {
        return Collection::make($route->middleware())->map(function ($m) {
            return Collection::make(array_get($this->middleware, $m, $m));
        })->collapse()->all();
    }
1034501
protected function addWhereClausesToRoute( $route )
	{
		$where = isset( $route->getAction()['where'] ) ? $route->getAction()['where'] : [];
		$route->where( array_merge( $this->patterns, $where ) );

		return $route;
	}
423438
public function setRoutes(array $routes)
    {
        $toIterate = RouteConfig::defaultRouteTypes();
        foreach ($routes as $key => $val) {
            if (in_array($key, $toIterate) && isset($this->routes[$key])) {
                $this->routes[$key] = array_merge($this->routes[$key], $val);
            } else {
                $this->routes[$key] = $val;
            }
        }

        return $this;
    }
1018928
function create($route) {
        $route->pattern = $this->parser->trimPath($route->pattern);
        return parent::create($route);
    }
870337
public static function staticAdminLogon($route = null)
    {
        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
            if ('login' !== Config::getParam('admin.login')) {
                return AdminServices::getInstance()->setAdminHeaders();
            } else {
                $form = new LoginForm();
                $form->setData(array("route" => $route));
                $form->build();
                $tpl = Template::getInstance();
                $tpl->setPublicZone(true);
                return $tpl->render("login.html.twig", array(
                    'form' => $form,
                ));
            }
        } else {
            return UserController::showAdminManager();
        }
    }