Adds a new definition of Route.

@param MRoute $route
@throws MInvalidClassNameException
@throws MInvalidMethodNameException
@throws MInvalidRoleException
@throws MInvalidRouteTypeException
338989
public function add( MRoute $route )
    {
        $this->validateRoute( $route );

        $this->routeList->insert( $route->getRole(), $route );
    }
632130
public function add(Route $route, array $params = [])
    {
        $callback = $route->getCallable();
        if (empty($callback)) {
            return;
        }

        $this->routes[] = $route->getRoute();
        $paramNames = $route->getParamNames();
        foreach ($paramNames as $name) {
            if (isset($params[$name])) {
                $this->setParam($name, $params[$name]);
            }
        }

        if (is_array($callback)) {
            $this->callable = array_merge($this->callable, $callback);
        } elseif (!in_array($callback, $this->callable)) {
            $this->callable[] = $callback;
        }
    }
953160
public function addRoute($method, $route, $callback)
    {
        $route = $this->router->addRoute(strtoupper($method), $this->prefix . '/' . $route, $callback);

        $route->onAny(function($event, $arguments){
            $this->emit($event, $arguments);
        });

        $this->routes[] = $route;

        return $route;
    }
1111462
public function addRoute(array $methods, string $route, $handler): void
    {
        if ($methods === []) {
            throw new \InvalidArgumentException('Methods is empty');
        }

        if (\is_callable($handler)) {
            $handler = \Closure::fromCallable($handler);
        } elseif (!\is_array($handler)) {
            throw new \InvalidArgumentException('Handler is not a valid type: ' . \var_export($handler, true));
        }

        $parts = \explode('/', \trim($route, static::SEPARATOR_TRIM));

        if (!isset($parts[1]) && $parts[0] === '') {
            $parts = [];
        }

        $current = &$this->routes;
        foreach ($parts as $v) {
            if ($v[0] === '{' && $v[-1] === '}') {
                $v = \substr($v, 1, -1);
                if (\strpos($v, ':') !== false) {
                    [$name, $regexp] = \explode(':', $v, 2);

                    $regexp = '/^' . $regexp . '$/';
                    if (!isset($current['regexps'][$regexp])) {
                        $current['regexps'][$regexp] = [
                            'children' => [],
                            'regexps' => [],
                            'name' => $name,
                        ];
                    }
                    $current = &$current['regexps'][$regexp];
                } else {
                    if (!isset($current['others'])) {
                        $current['others'] = [
                            'children' => [],
                            'regexps' => [],
                            'name' => $v,
                        ];
                    }
                    $current = &$current['others'];
                }
            } else {
                if (!isset($current['children'][$v])) {
                    $current['children'][$v] = [
                        'children' => [],
                        'regexps' => [],
                    ];
                }
                $current = &$current['children'][$v];
            }
        }

        $current['route'] = $route;

        if (!isset($current['methods'])) {
            $current['methods'] = [];
        }

        foreach ($methods as $v) {
            $current['methods'][\strtoupper($v)] = $handler;
        }
    }
694861
public function addRouteDefinition(RouteDefinition $definition): void
    {
        $name = $definition->getName();

        if (isset($this->routesByName[$name])) {
            throw new \InvalidArgumentException("Route with name '$name' already exists");
        }

        $routeId = \count($this->routeDefinitions);
        $segments = $definition->getSegments();

        $this->routeDefinitions[$routeId] = $definition->getDefinitionCache();
        $this->routesByName[$name] = $routeId;

        if ($definition->isStatic()) {
            $this->staticRoutes[implode('/', $segments)][] = $routeId;
            return;
        }

        foreach ($segments as $i => $segment) {
            $this->segmentValues[$i][$segment][$routeId] = $routeId;

            if (!isset($this->segmentCounts[$i])) {
                $this->segmentCounts[$i] = [];
            }
        }

        $this->segmentCounts[\count($segments)][$routeId] = $routeId;
    }
972092
protected function substituteImplicitBindings( $route )
	{
		$parameters = $route->parameters();

		foreach ( $route->signatureParameters( Model::class ) as $parameter )
		{
			$class = $parameter->getClass();

			if ( array_key_exists( $parameter->name, $parameters ) && !$route->getParameter( $parameter->name ) instanceof Model )
			{
				$method = $parameter->isDefaultValueAvailable() ? 'first' : 'firstOrFail';

				$model = $class->newInstance();

				$route->setParameter( $parameter->name, $model->where( $model->getRouteKeyName(), $parameters[$parameter->name] )->{$method()} );
			}
		}
	}
503352
public function addRoutes($routes)
    {
        if (!is_array($routes) && !$routes instanceof Traversable) {
            throw new \Exception('Routes should be an array or an instance of Traversable');
        }
        foreach ($routes as $route) {
            call_user_func_array([$this, 'add'], $route);
        }
    }
661403
public function add(ParsedRoute $route)
    {
        foreach ($route->getMethods() as $method) {
            $this->routes[$method][] = $route;

            if (!empty($route->getName())) {
                $this->namedRoutes[$route->getName()] =& $route;
            }
        }
    }
876134
public function addRoutes($routes = array())
    {
        if (!$this->isRegistered()) {
            $this->registerWordpressAction();
        }

        $this->route->addPossibilities($routes);
    }
586966
protected function setAttributes(Route $route)
    {
        $this->namespace = array_key_exists('namespace', $route->attributes)
            ? $route->attributes['namespace']
            : null;
        $this->controller = array_key_exists('controller', $route->attributes)
            ? ucfirst($this->normalize($route->attributes['controller']))
            : null;
        $this->action = array_key_exists('action', $route->attributes)
            ? $this->normalize($route->attributes['action'])
            : null;
        $this->args  = array_key_exists('args', $route->attributes)
            ? $route->attributes['args']
            : [];
        return $this;
    }
1194780
def add_route(self, route):
        ''' '''
        self.routes.append(route)
        self.router.add(route.rule, route.method, route, name=route.name)
        if DEBUG: route.prepare()
1178568
public function addRouteItem(string $linkName, array $route): void
    {
        $url = isset($route['params']) ? $this->urlGen->generate($route['route'], $route['params']) :
                                        $this->urlGen->generate($route['route']);

        $this->addSimpleItem($linkName, $url);
    }
195287
public function add($name, Route $route)
    {
        unset($this->routes[$name]);

        $this->routes[$name] = $route;
    }
556024
public function updateInstances($route, $request)
    {
        $this->request = $request;
        if ($request) {
            $this->uri = urldecode($request->path());
        }

        $this->route = $route;
        if ($route) {
            $this->action = $route->getActionName();

            $actionSegments   = Str::parseCallback($this->action, null);
            $this->controller = head($actionSegments);
            $this->method     = last($actionSegments);
        }
    }
264698
private function createRouteDefinition($routeName, Route $route)
    {
        if (null === $definition = $this->findRouteDefinitionByRouteName($routeName)) {
            $definition = new RouteDefinition($routeName, $this->resolveRouteOptions($route, $routeName));
            if (null === $parentRouteName = $definition->getParentRouteName()) {
                // If parent route name is null => home page child
                $definition->setParentRouteName($this->homeRouteName);
                $this->homeDefinition->appendChild($definition);
            } else {
                // Creates parent route definition if needed
                $parentRoute = $this->findRouteByName($parentRouteName);
                $parentDefinition = $this->createRouteDefinition($parentRouteName, $parentRoute);
                $parentDefinition->appendChild($definition);
            }
        }

        return $definition;
    }
1066178
public function add(Route $route): self{
        if(isset($this->leaves[$route])){
            throw new \InvalidArgumentException(
                "Route is already registered."
            );
        }

        if(array_key_exists($route->getName(), $this->routes)){
            throw new \InvalidArgumentException(
                "Same name ({$route->getName()}) route is already registered."
            );
        }

        $queue  = new \SplQueue();

        foreach(explode("/", $route->getPath()) as $segment){
            $queue->enqueue($segment);
        }

        $queue->dequeue(); // 先頭のセグメントはすでにある(ルートノード)

        $node   = $this->rootNode;

        while(!$queue->isEmpty()){
            $segment    = $queue->dequeue();

            $node->addChild($segment);

            $node   = $node->getChild($segment);
        }

        $node->addRoute($route);

        $this->routes[$route->getName()]    = $route;
        $this->leaves[$route]               = $node;

        return $this;
    }
482432
public function addRoute(Route $route) {
        if (!in_array($route, $this->routes)) {
            $this->routes[] = $route;
        }
    }