Add new route to routes array

@param  string $url
@param  string $method
@param  mixed  $action

@return void
767624
public function add($url, $method, $action)
	{	
		$route = $this->factory->create($url, $method, $action);

		$this->routes[] = $route;

		foreach ($route->getMethod() as $method) {
			$this->routesByMethod[$method][] = $route;
		}
	}
386868
function route(
    $path = '/', $actions, $method = Router::ANY_METHOD, $name = null, array $filters = [], array $events = []
    )
    {
        if (is_array($path)) {
            foreach ($path as $p) {
                $this->collection[$name ?: count($this->collection)] = (new Route($this->Parser))
                        ->route($p, is_array($actions) ? $actions : [$actions], $method, $name, $filters, $events);
            }
        } else {
            $this->collection[$name ?: count($this->collection)] = (new Route($this->Parser))
                    ->route($path, is_array($actions) ? $actions : [$actions], $method, $name, $filters, $events);
        }

        return $this;
    }
877439
protected function newRoute($methods, $uri, $action)
    {
        // WordPress condition could have been already applied.
        // We only try one more time to fetch them if no conditions
        // are registered. This avoids the overwrite of any pre-existing rules.
        if (empty($this->conditions)) {
            $this->setConditions();
        }

        return (new Route($methods, $uri, $action))
            ->setRouter($this)
            ->setContainer($this->container)
            ->setConditions($this->conditions);
    }
1293498
public function findRoute($method, $uri)
	{
		$this->method = $method;
		if ($this->routesTree === null) {
			$this->routesTree = $this->parseRoutes($this->rawRoutes);
		}

		$search = $this->normalize($uri);

		$node   = $this->routesTree;
		$params = [];

		//loop every segment in request url, compare it, collect parameters names and values
		foreach ($search as $key => $v) {

			if (isset($node[$v["use"]])) {
				$node = $node[$v["use"]];
			} else if (isset($node["*"])) {

				$subnode = $node["*"];
				if (($definitions = $this->rawRoutes[$subnode["routeName"]]["definitions"]) !== null) {
					if (isset($definitions[$subnode["name"]])) {
						$definition = $definitions[$subnode["name"]];
						$regex = ($definition[0] === "(") ? $definition : $this->getMatchType($definition, "(.*)");

						if ($regex === "(.*)") {
							break;
						} else {
							if (!preg_match($regex, $v['name'])) {
								throw new RouteNotFoundException("Route for uri: {$uri} was not found");
							}
						}
					}
				}
				// This sets node to continue
				$node = $subnode;
				$params[$subnode["name"]] = $v["name"];

			} else if (isset($node["?"])) {
				$node = $node["?"];

				if (($definitions = $this->rawRoutes[$method][$node["routeName"]]["definitions"]) !== null) {
					if (isset($definitions[$node["name"]])) {
						$definition = $definitions[$node["name"]];
						$regex = ($definition[0] === "(") ? $definition : $this->getMatchType($definition, "any");

						if ($regex === "(.*)") {
							$c = count($search);
							for ($i=$key; $i < $c; $i++) {
								$b[] = $search[$i]["use"];
							}
							$params[$node["name"]] = $b;
							break;
						} else {
							if (!preg_match($regex, $v['name'])) {
								continue;
							}
							$node = $node["?"];
							$params[$node["name"]] = $v["name"];
						}
					}
				}

				$params[$node["name"]] = $v["name"];
			} else {
				throw new RouteNotFoundException("Route for uri: {$uri} was not found");
			}

		}

		// Check for route with optional parameters that are not in request url until valid action is found
		// This make tree to go to last key
		while (!isset($node["exec"]) && isset($node["?"])) {
			$node = $node["?"];
		}

		if (isset($node["exec"])) {
			if (!isset($node["exec"]["method"][$method])
				&& !isset($node["exec"]["method"]["any"])
			) {
				throw new MethodNotAllowedException("Method: {$method} is not allowed for this route");
			}

			$Route = $node["exec"]["method"][$method];
			$Route->params = $params;
			if ($a = is_array($Route->action) || is_string($Route->action)) {
				if ($a) {
					$Route->action = [$Route->namespace.$Route->action[0], $Route->action[1]];
				} else {
					$Route->action = $Route->namespace.$Route->action;
				}
			}
			return $Route;
		}
		throw new RouteNotFoundException("Route for uri: {$uri} was not found");
	}
382707
public function addRoute($method, $route, $action, $extra = [])
	{
		$name = (isset($extra["name"])) ? $extra["name"] : $route;

		if (isset($this->rawRoutes[$name])) {
			$Route = $this->rawRoutes[$name];
		} else {
			$Route              = clone $this->Route;
			$Route->route       = $this->baseUri.$route;
			$Route->name 		= $name;
		}

		$Route->addExtra($extra);
		$methods = [];
		if ("ANY" === $method) {
			$methods["GET"]  = $action;
			$methods["POST"] =& $methods["GET"];
			$methods["PUT"]  =& $methods["GET"];

			$Route->methods = $methods;
			$Route->action = $action;

			$this->rawRoutes[$name] = $Route;
		} else {

			$arrayedMethod = (array) $method;
			$count = count($arrayedMethod);

			for ($i = 0; $i < $count; $i++) {
				if (!isset($this->allowedMethods[$arrayedMethod[$i]])) {
					throw new InvalidMethodException("Method: " . $arrayedMethod[$i] . " is not valid");
				}
				$method = $arrayedMethod[$i];
				$Route->action = $action;
				$Route->method = $method;
				$Route->name = $name;
				$this->rawRoutes[$name] = $Route;
			}
		}


		return $Route;
	}
1224178
public function addRoute($actionName, Route $route)
    {
        !array_key_exists($actionName, $this->routes) or \PhpBoot\abort("repeated @route for {$this->className}::$actionName");
        $this->routes[$actionName] = $route;
    }
1136337
protected function createRoute($methods, $uri, $action)
    {
        if (is_callable($action)) {
            $action = array('uses' => $action);
        }

        // If the route is routing to a controller we will parse the route action into
        // an acceptable array format before registering it and creating this route
        // instance itself. We need to build the Closure that will call this out.
        else if ($this->actionReferencesController($action)) {
            $action = $this->convertToControllerAction($action);
        }

        // If no "uses" property has been set, we will dig through the array to find a
        // Closure instance within this list. We will set the first Closure we come
        // across into the "uses" property that will get fired off by this route.
        else if (! isset($action['uses'])) {
            $action['uses'] = $this->findActionClosure($action);
        }

        if (isset($action['middleware']) && is_string($action['middleware'])) {
            $action['middleware'] = explode('|', $action['middleware']);
        }

        $route = $this->newRoute(
            $methods, $uri = $this->prefix($uri), $action
        );

        // If we have groups that need to be merged, we will merge them now after this
        // route has already been created and is ready to go. After we're done with
        // the merge we will be ready to return the route back out to the caller.
        if (! empty($this->groupStack)) {
            $this->mergeGroupAttributesIntoRoute($route);
        }

        $this->addWhereClausesToRoute($route);

        return $route;
    }
256594
private function addRoute($method, $pattern, $action)
    {

        if (is_array($method)) {
            foreach ($method as $verb) {
                $this->routes[$verb . $pattern] = ['method' => $verb, 'uri' => self::patternFactory($pattern), 'action' => $action];
            }
        } else {
            $this->routes[$method . $pattern] = ['method' => $method, 'uri' => self::patternFactory($pattern), 'action' => $action];
        }
    }
361756
public function map($method, $route, $action)
    {
        return $this->getRouter()->map($method, $route, $this->bindClosureToInstance($action, $this));
    }
811207
protected function newRoute($methods, $uri, $action)
    {
        return with(new Route($methods, $uri, $action))
            ->setRouter($this)
            ->setContainer($this->container);
    }
7297
private function _routeCron($src, $controller, $action) {
        $this->request->name = '-' . $src . '_' . $controller . '_' . $action;
        $this->request->src = $src;
        $this->request->controller = $controller;
        $this->request->action = $action;
        $this->request->auth = new Auth($this->request->src);
        $this->_route = true;
    }
1318730
protected function handle(string $path, callable $action, $method, string $name = null): HttpRoute
    {
        if (!is_array($method)) {
            $method = [$method];
        }
        /** @var HttpRoute $route */
        $route = $this->data->createRoute($this->prefix . $path, $action, $name);
        $route->method(...$method);
        return $route;
    }
731647
public function patch(string $uri, string $controller, string $action)
    {
        $this->addRoute('PATCH', $uri, $controller, $action);
    }
270129
public function add($rule, $action = null)
    {
        $route = $this->di->get('route');
        $route->set($rule, $action);
        $this->routes[] = $route;

        // Set as default route
        if ($rule == "*") {
            $this->defaultRoute = $route;
        }
        
        return $route;
    }
1144471
public function addRoute($methods, $uri, $action)
    {
        if (is_string($action)) {
            $action = ['uses' => $action];
        } elseif ($action instanceof Closure) {
            $action = [$action];
        }

        $action = $this->mergeLastGroupAttributes($action);

        $uri = $uri === '/' ? $uri : '/'.trim($uri, '/');

        if (! empty($action['prefix'])) {
            $uri = '/'.rtrim(trim($action['prefix'], '/').'/'.trim($uri, '/'), '/');

            unset($action['prefix']);
        }

        $action['uri'] = $uri;

        $action = $this->addRouteMiddlewares($action);

//        echo $action;
//        return $this->adapter->addRoute((array) $methods, $action['version'], $uri, $action);
        return $this->addRoute((array) $methods, $action['version'], $uri, $action);
    }
1179995
public function any($uri, $action = null) {
        return $this->addRoute(Route::HTTP_METHODS, $uri, $action);
    }
1126903
public function run($url = null, $method = null)
    {
        $route = $this->altoRouter->match($url, $method);
        if (!$route) {
            throw new NotFoundException(((isset($_SERVER['REQUEST_URI']) && !empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : (($url != null) ? $url : "/")) . " is not reachable.");
        }
        if (!isset($route['target']['c']) || !isset($route['target']['a']) || !isset($route['params'])) {
            throw new FrameworkException('Internal Framework Error. [!BAD_ROUTER_TARGET]', 001);
        }
        if (is_callable(array($route['target']['c'], 'getInstance'))) {
            $controller = $route['target']['c']::getInstance();
            if (method_exists($controller, $route['target']['a'])) {
                call_user_func(array($controller, $route['target']['a']), array_values($route['params']));
                $controller->response->send();
            } else {
                throw new FrameworkException('Internal Framework Error. [METHOD_DOES_NOT_EXISTS]', 002);
            }
        } else {
            throw new FrameworkException('Internal Framework Error. [CONTROLLER_DOES_NOT_EXISTS]', 003);
        }
    }