Route a controller to a URI with wildcard routing.

@param  string $uri
@param  string $controller
@param  array $names

@deprecated since version 5.2.
961436
public function controller( $uri, $controller, $names = [] )
	{
		$prepended = $controller;

		// First, we will check to see if a controller prefix has been registered in
		// the route group. If it has, we will need to prefix it before trying to
		// reflect into the class instance and pull out the method for routing.
		if ( !empty( $this->groupStack ) )
			$prepended = $this->prependGroupUses( $controller );

		$routable = ( new ControllerInspector )->getRoutable( $prepended, $uri );

		// When a controller is routed using this method, we use Reflection to parse
		// out all of the routable methods for the controller, then register each
		// route explicitly for the developers, so reverse routing is possible.
		foreach ( $routable as $method => $routes )
			foreach ( $routes as $route )
				$this->registerInspected( $route, $controller, $method, $names );

		$this->addFallthroughRoute( $controller, $uri );
	}
369187
public static function href($controller = null, string $action = null, array $params = null): string
    {
        return Application::route()->href($controller, $action, $params);
    }
146574
public function redirect(Controller $Controller, $route) {
		if ($route['message'] != null) {
			$message = $route['message'];
			$element = $route['element'];
			$params = $route['params'];
			$this->Session->write("Message.{$route['key']}", compact('message', 'element', 'params'));
		}

		$Controller->redirect($route['redirect']);
	}
890808
protected function addPatchResourceUpdate($name, $base, $controller)
    {
        $uri = $this->getResourceUri($name) .'/{' .$base .'}';

        $this->router->patch($uri, $controller.'@update');
    }
731416
protected function Route($uri)
    {
         foreach($this->routes as $handler){
            
             if(is_string($handler)){
                 $res = $handler($uri);
             }                
              if($this->currentpage instanceof \Zippy\Html\WebPage){
                  break;
              } 
               
          }      
    }
1162572
public function makeController($controller)
    {
        $namespace = $this->router->getNamespace();

        $classname = "{$namespace}\\{$controller}";

        if (class_exists($classname)) {
            return $this->container->make($classname);
        }

        throw new RoutingException("Controller [{$classname}] do not exists.");
    }
1261595
public function routeController($controller): Controller
    {
        $actions = $this->getActions();

        foreach ($actions as $key => $action) {
            $method = ucfirst(Inflector::pathAction($action));

            if (method_exists($this, 'set' . $method . 'Route')) {
                $this->{'set' . $method . 'Route'}(Inflector::deCamelize($controller), $action);
            }
        }

        $this->mapRoute();

        return $this;
    }
555794
public function ajax($patternUri, $action, $name)
    {
        $route = new Route("ajax", $patternUri, $action, $name);
        $this->container->addRoute($route);
        return $route;
    }
96844
private function addRoute($types = '', $uri, $action = [])
    {

        if (is_string($action)) {
            $action = ['_controller' => $action];
        }

        if (is_array($action)) {
            if (isset($action['as'])) {
                AsCollector::addAs($action['as'], $uri);
            }
        }

        $types = (array)$types;

        foreach ($types as $type) {
            $type = mb_convert_case($type, MB_CASE_UPPER);

            $add = [
                'uri' => isset(static::$firing['when']) ? $this->createWhenUri($uri) : $uri,
                'action' => $action
            ];;

            // add group parameter to action variable
            if (isset(static::$firing['group'])) {
                $add['group'] = static::$firing['group'];
            }

            // add to collection
            static::$routes[$type][] = $add;
        }
        return $this;
    }
1243245
protected function createRoute($methods, $uri, $action)
    {
        // Transform an action controller to a Closure action
        if ($this->isActionController($action)) {
            $action = $this->convertToControllerAction($action);
        }

        // Create new route
        $route = $this->newRoute(
            $methods, $uri, $action
        );

        return $route;
    }
101238
public function setController($name, $controller=null)
	{
	    if ($name instanceof Controller) {
	        $controller = $name;
	        $sname = $controller->getName();
	    } elseif ($controller instanceof Controller) {
	        $sname = $name && !is_numeric($name) ? $name : $controller->getName();
	    } else {
	        if ($controller) {
	            $class_name = Ioc::findClass($controller, 'controller');
	        } else {
	            $class_name = Ioc::findClass($name, 'controller');
	        }
	        
	        if ($class_name && is_subclass_of($class_name, "\\Wslim\\Console\\Controller")) {
	            $sname = is_numeric($name) ? null : $name;
	            $controller =  new $class_name($sname);
	            if (!$sname) {
	                $sname = $controller->getName();
	            }
	        } else {
	            throw new \LogicException(sprintf('Controller class "%s" is not exists.', $controller));
	        }
	    }
	    
	    if (!$controller->isEnabled()) {
	        return;
	    }
	    
	    if (null === $controller->getDefinition()) {
	        throw new \LogicException(sprintf('Controller class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($controller)));
	    }
	    
	    $this->controllers[$sname] = $controller;
	    
	    foreach ($controller->getAliases() as $alias) {
	        $this->controllers[$alias] = $controller;
	    }
	    
	    return $controller;
	}
242883
public function initCron($src, $controller, $action) {
        if (!Config::config()['user']['debug']['maintenance']) {
            $this->_routeCron($src, $controller, $action);

            if ($this->_route == true) {
                $this->_setFunction($this->request->src);
                $this->_setEvent($this->request->src);
            }
        }
    }
1126367
public function get(string $uri, string $controller, string $action)
    {
        $this->addRoute('GET', $uri, $controller, $action);
    }
542358
protected function redirect($controller = null, $action = 'index', array $parameters = []) : Response
    {
        $host = 'http://'. $_SERVER['HTTP_HOST'];

        if ($controller === null) {

            // Apparently we want to redirect to homepage, so the host will be sufficient
            if ($action === 'index') {
                return $this->redirectUrl($host);
            }
            
            $controller = $this->getControllerName();
        }

        if ($action === 'index') {
            $action = '';
        }else{
            $action = '/' . $action;
        }

        return $this->redirectUrl(sprintf('%s/%s%s', $host, lcfirst($controller), $action), $parameters);
    }
409845
public function addDelete(string $uri, string $handler, string $name = null)
    {
        $this->addRoute("DELETE", $uri, $handler, $name);
    }
188139
public function route($name, $pattern, $controller, array $arguments = [], array $methods = [])
    {
        $this->router()->register($name, new Route($pattern, $controller, $arguments, $methods));

        return $this;
    }
730889
protected function parseRoutes($uri)
    {
        if (Container::get('config')->get('url_route_annotation')) {
            $finder = new Finder();
            $finder
                ->in(Container::get('config')->get('app_full_path') . '/controllers')
                ->name('*.php');
            $controllerNamespaces = [];
            foreach ($finder as $file) {
                array_push($controllerNamespaces, '\\' . Container::get('config')->get('namespace_prefix') . 'controllers\\' . $file->getBasename('.' . $file->getExtension()));
            }

            foreach ($controllerNamespaces as $namespace) {
                $classReflector = new ReflectionClass($namespace);
                $classAnnotations = new Annotations($classReflector);

                foreach ($classReflector->getMethods() as $methodReflector) {
                    $methodAnnotations = new Annotations($methodReflector);
                    if (!isset($methodAnnotations['route'])) {
                        continue;
                    } else {
                        $routeAnnotations = $methodAnnotations['route'];
                        if (!isset($routeAnnotations['uri'])) {
                            throw new ConfigException('Route annotations error');
                        }

                        $controllerName = $classReflector->getShortName();
                        $actionName = $methodReflector->getName();
                        $route = $controllerName . '/' . $actionName;
                        if (isset($routeAnnotations['params'])) {
                            $route .= '/' . $routeAnnotations['params'];
                        }

                        if (!isset($routeAnnotations['method'])) {
                            $this->routes[$routeAnnotations['uri']] = $route;
                        } else {
                            $this->routes[$routeAnnotations['uri']][$routeAnnotations['method']] = $route;
                        }

                        unset($route);
                    }
                }
            }
        } else {
            $this->routes = Container::get('config')->get('url_route');
        }

        $hostName = Container::get('request')->getHostName();

        if (isset($this->routes[$hostName])) {
            $this->routes = $this->routes[$hostName];
        }

        // Get HTTP verb
        $httpVerb = isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : 'cli';

        if (null != $this->routes) {
            foreach ($this->routes as $key => $val) {
                // Check if route format is using HTTP verbs
                if (is_array($val)) {
                    $val = array_change_key_case($val, CASE_LOWER);
                    if (isset($val[$httpVerb])) {
                        $val = $val[$httpVerb];
                    } else {
                        continue;
                    }
                }

                // Does the RegEx match?
                if (preg_match('#^' . $key . '$#', $uri, $matches)) {
                    // Are we using callbacks to process back-references?
                    if (!is_string($val) && is_callable($val)) {
                        // Remove the original string from the matches array.
                        array_shift($matches);

                        // Execute the callback using the values in matches as its parameters.
                        $val = call_user_func_array($val, $matches);
                    } // Are we using the default routing method for back-references?
                    elseif (strpos($val, '$') !== false && strpos($key, '(') !== false) {
                        $val = preg_replace('#^' . $key . '$#', $val, $uri);
                    }

                    return $val;
                }
            }
        }
    }