Adds a route before another.

@param string $before The before route name
@param string $name   The route name
@param Route  $route  A Route instance

@throws \InvalidArgumentException If the before route name cannot be found
340085
public function addBefore($before, $name, SymfonyRoute $route)
    {
        $newRoute = $route;
        foreach ($this->all() as $routeName => $route) {
            if (null !== $newRoute && $before === $routeName) {
                $this->add($name, $newRoute);
                $newRoute = null;
            }

            if (null === $newRoute) {
                // move the existing route onto the end of collection
                $this->add($routeName, $route);
            }
        }

        if (null !== $newRoute) {
            throw new \InvalidArgumentException(sprintf('The route "%s" cannot be added before "%s", because the route "%2$s" was not found.', $name, $before));
        }
    }
1242159
public function add( Route $route ){
		$routeId	= $route->getId();
		if( array_key_exists( $routeId, $this->routes ) ){
			throw new \DomainException( sprintf(
				'A route for pattern and method is already registered: %2$s %1$s',
				$route->getPattern(),
				$route->getMethod()
			) );
		}
		$this->routes[$routeId]	= $route;
		return $routeId;
	}
701636
public function set($route)
    {
        if (is_string($route)) {
            $this->routes[] = array(
                    'pattern' => $route
                ) + $this->routeOptions;
        } elseif (is_array($route)) {
            $this->routes[] = $route + $this->routeOptions;
        } else {
            throw new \InvalidArgumentException(sprintf(
                'Expected argument of type string or array, "%s" given',
                is_object($route) ? get_class($route) : gettype($route)
            ));
        }

        return $this;
    }
179811
public function middleware($name)
    {
        if (is_string($name)) {
            app()->addRouteMiddleware($name);
        } else if (is_array($name)) {
            foreach ($name as $middlewareName) {
                app()->addRouteMiddleware($middlewareName);
            }
        }
    }
748333
private function prepare($route)
    {
        $this->route = $route;
        $this->setBeforeFilter($route->before());
        $this->setAfterRelease($route->after());
    }
996126
public function before(Request $request, Application $app, $roleRoute = null)
    {
        return parent::before($request, $app, 'extensions');
    }
841206
public function addRoute(string $prefix, $route)
    {
        list($prefix, $staticPrefix) = $this->getCommonPrefix($prefix, $prefix);

        for ($i = \count($this->items) - 1; 0 <= $i; --$i) {
            $item = $this->items[$i];

            list($commonPrefix, $commonStaticPrefix) = $this->getCommonPrefix($prefix, $this->prefixes[$i]);

            if ($this->prefix === $commonPrefix) {
                // the new route and a previous one have no common prefix, let's see if they are exclusive to each others

                if ($this->prefix !== $staticPrefix && $this->prefix !== $this->staticPrefixes[$i]) {
                    // the new route and the previous one have exclusive static prefixes
                    continue;
                }

                if ($this->prefix === $staticPrefix && $this->prefix === $this->staticPrefixes[$i]) {
                    // the new route and the previous one have no static prefix
                    break;
                }

                if ($this->prefixes[$i] !== $this->staticPrefixes[$i] && $this->prefix === $this->staticPrefixes[$i]) {
                    // the previous route is non-static and has no static prefix
                    break;
                }

                if ($prefix !== $staticPrefix && $this->prefix === $staticPrefix) {
                    // the new route is non-static and has no static prefix
                    break;
                }

                continue;
            }

            if ($item instanceof self && $this->prefixes[$i] === $commonPrefix) {
                // the new route is a child of a previous one, let's nest it
                $item->addRoute($prefix, $route);
            } else {
                // the new route and a previous one have a common prefix, let's merge them
                $child = new self($commonPrefix);
                list($child->prefixes[0], $child->staticPrefixes[0]) = $child->getCommonPrefix($this->prefixes[$i], $this->prefixes[$i]);
                list($child->prefixes[1], $child->staticPrefixes[1]) = $child->getCommonPrefix($prefix, $prefix);
                $child->items = [$this->items[$i], $route];

                $this->staticPrefixes[$i] = $commonStaticPrefix;
                $this->prefixes[$i] = $commonPrefix;
                $this->items[$i] = $child;
            }

            return;
        }

        // No optimised case was found, in this case we simple add the route for possible
        // grouping when new routes are added.
        $this->staticPrefixes[] = $staticPrefix;
        $this->prefixes[] = $prefix;
        $this->items[] = $route;
    }
123799
public function route($name = ''){
        $routes = AsCollector::getAs();

        if (isset($routes[$name])) {
            $this->to($routes[$name]);
        }else{
            throw new RouteNotFoundException(sprintf('%s Route Not Found'));
        }
    }
605441
public function addRoute(Route $route)
	{
		foreach ($route->getMethods() as $method)
		{
			$this->routes[$method][/*$route->uri*/] = $route;
		}
		
		$this->allRoutes[] = $route;

		return $this;
	}
418926
private function processRouteInfos($name, array $routeInfos)
    {
        $className = null;
        if (isset($routeInfos['sequence'])) {
            $className = $routeInfos['sequence'];
            $this->container['core']['router']->addRouteSequence($className);
        }

        if (isset($routeInfos['pattern'])) {
            if (!isset($routeInfos['arguments'])) {
                $routeInfos['arguments'] = array();
            }

            $route = new Route($routeInfos['pattern'], $routeInfos['arguments'], $className);

            if (isset($routeInfos['defaults'])) {
                $route->defaults($routeInfos['defaults']);
            }
            if (isset($routeInfos['params'])) {
                $route->pushRequestParams($routeInfos['params']);
            }
            $this->container['core']['router']->addRoute($route, $name);
        }
    }
1062085
public function addRoute(Route $route, array $parameterIndexNameMap)
    {
        if ($route->allowsAnyHttpMethod()) {
            $this->defaultRouteData = MatchedRouteData::from($parameterIndexNameMap, $route);
        } else {
            $this->httpMethodRouteDataMap[] = [$route->getHttpMethods(), MatchedRouteData::from($parameterIndexNameMap, $route)];
        }
    }
427369
public function prependInit(callable $middleware, $name = null)
    {
        $this->add(self::INIT, $name, $middleware, true);
    }
409754
public function addRoute(string $type, string $name, string $route): void{
        if (!isset($this->routes[$name])) {
            $this->routes[$name] = [];
        }
        $this->routes[$name][$type] = $route;
    }
930837
public static function addRoute($route, $file = 'web', $before = '\n')
    {
        $route = str_replace('\\', '/', $route);
        $routeFilePath = base_path('routes/' . $file . '.php');
        $routeFile = file_get_contents($routeFilePath);
        if (!str_contains($routeFile, $route)) {
            $routeEndIndex = strrpos($routeFile, $before);
            $routeFile = substr($routeFile, 0, $routeEndIndex) .
                "    " . $route . "\n" .
                substr($routeFile, $routeEndIndex);
            file_put_contents($routeFilePath, $routeFile);
        }
    }
635793
public function addNamedRoute($name, \Yee\Route $route)
    {
        if ($this->hasNamedRoute($name)) {
            throw new \RuntimeException('Named route already exists with name: ' . $name);
        }
        $this->namedRoutes[(string) $name] = $route;
    }
42993
public function addRoute(Route $route, $name = null)
    {
        if (null === $name) {
            // used as a flag to know which routes will need a name later
            $name = '_unnamed_route_'.spl_object_hash($route);
        }

        $this->routes[$name] = $route;

        return $this;
    }
1142819
public function addRouteByConfig($name, $route, $package = null, $prefix = '/')
    {
        if ($package) {
            if (!$package instanceof AbstractPackage) {
                $package = $this->getPackageResolver()->getPackage($package);
            }

            $pattern = Arr::get($route, 'pattern');

            $route['pattern'] = rtrim($prefix, '/ ') . $pattern;

            $route['pattern'] = '/' . ltrim($route['pattern'], '/ ');

            $route['extra']['package'] = $package->getName();

            $name = $package->getName() . '@' . $name;
        }

        $pattern      = Arr::get($route, 'pattern');
        $variables    = Arr::get($route, 'variables', []);
        $allowMethods = Arr::get($route, 'method', []);

        if (isset($route['controller'])) {
            $route['extra']['controller'] = $route['controller'];
        }

        if (isset($route['action'])) {
            $route['extra']['action'] = $route['action'];
        }

        if (isset($route['hook'])) {
            $route['extra']['hook'] = $route['hook'];
        }

        $routeObject = new Route($name, $pattern, $variables, $allowMethods, $route);

        $this->addRoute($routeObject);

        return $routeObject;
    }