Prepare the routes assing them to their containers

@param array		$routes
@return void
961014
protected static function prepare( $routes ) 
	{	
		// flatten if needed
		if ( ClanCats::$config->get( 'router.flatten_routes' ) ) 
		{
			$routes = static::flatten( $routes ); 
		}
		
		foreach( $routes as $uri => $route ) 
		{	
			// check for an alias to a private
			if ( is_string( $route ) ) 
			{
				if ( substr( $route, 0, 1 ) == '#' ) 
				{
					$route = static::$privates[$route];
				}
			}
			
			// does this uri contain an alias?
			if ( strpos( $uri, '@' ) !== false )
			{
				// is the entire route an alias
				if ( $uri[0] == '@' )
				{
					static::$aliases[substr( $uri, 1 )] = $route;
				}
				// does it just contain an alias
				else
				{
					list( $uri, $alias ) = explode( '@', $uri );
					static::$aliases[$alias] = $uri;
				}
			}
			
			// check for a private 
			if ( substr( $uri, 0, 1 ) == '#' ) 
			{
				static::$privates[$uri] = $route;
			}
			// just a normal one
			else 
			{
				static::$routes[$uri] = $route;
			}
		}
	}
1297958
public function addRoutes(array $routes = [])
    {
        foreach($routes as $route)
        {
            if ($route instanceof RouteInterface) $this->routes[] = $route;
        }
    }
433470
public static function configureRoutes(GroupInterface $routes): void
    {
        $routes->group('', function (GroupInterface $routes): void {

            $routes->addContainerConfigurators([
                L10nContainerConfigurator::CONFIGURATOR,
            ]);

            for ($i = 0; $i < 10 + 10 * 5; ++$i) {
                $routes->post("/posts$i/create", [PostsController::class, PostsController::METHOD_CREATE]);
            }

        });
    }
1363240
public static function matchAll(array $routes)
    {
        foreach ($routes as $mapping) {
            list($methods, $route, $target, $name, $middleware) = $mapping;
            static::getInstance()->map($methods, $route, $target, $name, $middleware);
        }

        return static::getInstance();
    }
1201004
public function setRoutes(array $routes): TableList
    {
        $this->checkRoutesValidity($routes);
        $this->setAttribute('routes', $routes);

        return $this;
    }
869129
protected function setAliases(array $routes)
    {
        foreach ($routes as $command => $route) {

            if (!isset($route['alias'])) {
                continue;
            }

            if (isset($this->aliases[$route['alias']])) {
                throw new OverflowException("Command alias '{$route['alias']}' is not unique");
            }

            $this->aliases[$route['alias']] = $command;
        }
    }
482432
public function addRoute(Route $route) {
        if (!in_array($route, $this->routes)) {
            $this->routes[] = $route;
        }
    }
381034
private function application(array $routes)
    {
        // RouteGroup Callable
        return function(\League\Route\RouteGroup $router) use ($routes)
        {
            // Build application routes based on configuration
            foreach ($routes as $route) {
                // Map request to router
                $router->map($route['method'], $route['route'], $route['controller']);
            }
        };
    }
1124515
public static function all( $routes ) 
	{

		/* Call all functions that are to be executed before routing */
		foreach( self::$beforeFuncs as $beforeFunc ) {
			if( $beforeFunc[1] ) {
				call_user_func_array( $beforeFunc[0] , $beforeFunc[1] );
			} else {
				call_user_func( $beforeFunc[0] );
			}
		}

		self::$routes = $routes;
		$method = strtolower($_SERVER['REQUEST_METHOD']);
		$path = '/';
		$handler = null;
		$matched = array();
		if ( !empty ( $_SERVER['PATH_INFO'] ) ) {
			$path = $_SERVER['PATH_INFO'];
		} else if ( !empty ( $_SERVER['REQUEST_URI'] ) ) {
            $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
		}

		if ( isset($routes[$path] ) ) {
			if( is_array( $routes[$path] ) ) {
				$handler = $routes[$path][0];
			} else {
				$handler = $routes[$path];
			}
		} else if ( $routes ) {
			
			$regex = array(
				'/{i}/',
				'/{s}/',
				'/{a}/'
				);

			$replacements = array(
				'([\d]+)'	,
				'([a-zA-Z]+)',
				'([\w-]+)'
				);

			foreach ( $routes as $routePath => $routeDesc ){
				$routePath = preg_replace( $regex, $replacements, $routePath );
				if( preg_match( '#^/?' . $routePath . '/?$#', $path, $matches ) ){
					if( is_array( $routeDesc ) ) {
						$handler = $routeDesc[0];
						if( isset( $routeDesc[2] )) {
							$middleware = $routeDesc[2];
						}
					}
					else 
						$handler = $routeDesc;
					$matched = $matches;
					break;
				}
			}
		}
		unset( $matched[0] );

		if( isset($middleware) ){
			$newMatched = self::callFunction( $middleware, $matched, $method );
			/* If new wildcard param are there pass them to main handler */
			if( $newMatched ) { 
				self::callFunction( $handler, $newMatched, $method );
			} else {
				self::callFunction( $handler, $matched, $method );
			}
		} else {
			self::callFunction( $handler, $matched, $method );
		}

		/* Call all the function that are to be executed after routing */
		foreach( self::$afterFuncs as $afterFunc )
			if( $afterFunc[1] ) {
				call_user_func_array( $afterFunc[0] , $afterFunc[1] );
			} else {
				call_user_func( $afterFunc[0] );
			}
	}
912849
public function addRoutesFromArray(array $routes)
    {
        foreach ($routes as $name => $route) {
            $this->addRouteFromArray($name, $route);
        }
        return $this;
    }
1250041
protected function getRouteActions($routes)
    {
        $actions = array();

        // iterate for all routes
        foreach ($routes->all() as $route){

            // if route is post and is direct exposed
            if (in_array('POST', $route->getMethods()) == true && $route->isDirect()){
                $apiParts = $this->getRouteApiParts($route);

                if ($apiParts['exposed']){
                    $path = $apiParts['path'];
                    unset($apiParts['path']);
                    unset($apiParts['exposed']);

                    $actions[$path][] = $apiParts;
                }
            }

        }

        return $actions;
    }
112065
protected function setMethods($methods): void
    {
        if (\is_string($methods)) {
            $methods = [$methods];
        } elseif (!\is_array($methods)) {
            throw new RouterException('Method invalid');
        }

        foreach ($methods as $method) {
            if (!\in_array($method, Request::$methods, true)) {
                throw new RouterException('Method invalid: ' . $method);
            }
        }

        $this->methods = $methods;
    }
1007770
protected function initRoute(): void
    {
        foreach ($this->route as $route => &$pattern) {
            $pattern = $this->prepareRoutePattern($route);
        }
    }
1082957
protected function prepareRoutes()
    {
        $this->dispatcher = \FastRoute\simpleDispatcher(function (\FastRoute\RouteCollector $collector) {
            $router = new RouteCollection($this, $collector, '', [], '');

            // API
            $router->group(['middlewares' => ['api']], function (RouteCollection $router) {
                $route_file = app_path('routes_api.php');
                if (file_exists($route_file)) {
                    require $route_file;
                }
            });

            // WEB
            $router->group(['middlewares' => ['web']], function (RouteCollection $router) {
                $route_file = app_path('routes.php');
                if (file_exists($route_file)) {
                    require $route_file;
                }
            });
        });
    }
309541
public void setRoutes(java.util.Collection<OriginationRoute> routes) {
        if (routes == null) {
            this.routes = null;
            return;
        }

        this.routes = new java.util.ArrayList<OriginationRoute>(routes);
    }
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);
        }
    }
1367970
public function addModelRoutes($routes = array())
    {
        if (!$this->isRegistered()) {
            $this->registerWordpressAction();
        }

        $this->route->addModelPossibilities($routes);
    }