@param       $routeName
@param null  $controllerName
@param array $params
@param int   $code

@return Redirect
338747
public function redirect($routeName, $controllerName = NULL, $params = [], $code = 302)
    {
        return new Redirect($routeName, $controllerName, $params, $code);
    }
1278564
protected function _createURL($base, $controller, $action, $params, $searchDefined = true)
    {
        $params['controller'] = $controller;
        $params['action'] = $action;
        foreach ($this->urlRoutes as $route => $defined) { // first check those with strict params.
            $cBase = $base;
            $preparedParams = $params;
            if ($searchDefined) {
                if (is_numeric($route)) {
                    continue; // first only get those with defined conditions.
                }
                $match = true;
                foreach ($defined as $def => $value) { // first check if those exact values match.
                    if (($value || '0' === $value) && (!isset($params[$def]) || $params[$def] != $value)) {
                        $match = false;
                    } else {
                        unset($preparedParams[$def]);
                        if ('module' == $def) {
                            if (substr($cBase, -1 * strlen($value . '/')) == $value . '/') { // remove module from base url if it's there
                                $cBase = substr($cBase, 0, strlen($cBase) - strlen($value . '/'));
                            }
                        }
                    }
                }
                if (!$match) {
                    continue;
                }
            }
            $match = true;
            preg_match_all('/\(\?<([a-z0-9_\-]+)>.*?\)/', is_numeric($route) ? $defined : $route, $matches);
            if (!$matches) {
                continue;
            }
            $toReplace = array('\/' => '/');
            foreach ($matches[1] as $k => $word) {
                $match = $match & isset($params[$word]);
                if ($match) {
                    $toReplace[$matches[0][$k]] = $params[$word];
                    unset($preparedParams[$word]);
                } else {
                    break;
                }
            }

            if ($match) {
                unset($preparedParams['module']);
                return $cBase . str_replace(array_keys($toReplace), array_values($toReplace), is_numeric($route) ? $defined : $route) . $this->_params2string($preparedParams) . '.html';
            }
        }
        if ($searchDefined) {
            return $this->_createURL($base, $controller, $action, $params, false);
        }

    }
119213
protected function createRedirectResponse($url, $code = 301)
    {
        $response = $this->getComponentResponseFactory()
            ->createComponentResponse();

        $response->setCode($code)
                 ->getHeaders()
                    ->setHeader('Location', $url);

        return $response;
    }
1048267
public function amOnRoute($routeName, $params = [])
    {
        $route = $this->getRouteByName($routeName);

        if (!$route) {
            $this->fail("Could not find route with name '$routeName'");
        }

        $url = $this->generateUrlForRoute($route, $params);
        $this->amOnPage($url);
    }
744927
protected static function createRedirectResponse($url, $code, $headers)
    {
        $r = new RedirectResponse($url, $code, $headers);
        $r->setRequest(Request::getInstance());

        return $r;
    }
675961
public function redirectTo($routeName, $query = array(), $params = array())
    {
        $path = $this->pathFor($routeName, $params);

        if (!is_array($query)) {
            throw new \UnexpectedValueException('Router::redirectTo A query deve ser um array!');
        }

        if (count($query) > 0) {
            $path = $path.'?'.http_build_query($query);
        }
        $path = ($path == '') ? '/' :  $path;
        header("Location: ".$path);
        die;
    }
693901
public function seeCurrentRouteIs($routeName, array $params = [])
    {
        $router = $this->bootstrap->getBootstrap()->getResource('frontcontroller')->getRouter();
        $url = $router->assemble($params, $routeName);
        $this->seeCurrentUrlEquals($url);
    }
366293
protected function routeRedirectView($route, array $parameters = [], $statusCode = Response::HTTP_CREATED, array $headers = [])
    {
        return View::createRouteRedirect($route, $parameters, $statusCode, $headers);
    }
220984
protected function redirect($url, $code = 302)
    {
        $this->response->setStatusCode($code);
        $this->response->headers->set('Location', $url);

        return $this->response;
    }
840047
public static function url($url, $code = 302, $headers = array())
    {
        $r = static::createRedirectResponse((string) $url, $code, $headers);

        return $r;
    }
1218062
final public static function redirectToRoute(
        string $routename,
        array $params = array(),
        bool $domain = true,
        array $query = array(),
        int $status = 302
    ):void {

        $querystring = $domainstring = "";
        $route = self::generateRoute($routename, $params);
        if (!empty($query)) {
            foreach ($query as $one => $value) {
                $querystring .= "$one=$value".(((end($query) !== $value))? "&": "");
            }
            $querystring = "?$querystring";
        }

        if (true === $domain) {
            $server = new GlobalServer();
            $https = ((null !== $server->get("HTTPS") &&
                "on" === $server->get("HTTPS"))? "https://" : "http://");
            $domain = $https.$server->get("HTTP_HOST");
        }
        header("Location: $domain$route$querystring", $status);
        exit(1);
    }
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);
    }
539306
public function runRoute($command, $params = null, $path = '', $namespace = '')
    {
        if (! is_object($command)) {
			$segments = explode('@', $command);
			$controllerClass = str_replace([$namespace, '\\', '.'], ['', '/', '/'], $segments[0]);
			$controllerMethod = $segments[1];

            $controller = $this->resolveClass($controllerClass, $path, $namespace);
            if (method_exists($controller, $controllerMethod)) {
                echo call_user_func_array(
                    [$controller, $controllerMethod],
                    (!is_null($params) ? $params : [])
                );
                return;
            }

            return $this->exception($controllerMethod . ' method is not found in '.$controllerClass.' class.');
        } else {
            if (! is_null($params)) {
                echo call_user_func_array($command, $params);
                return;
            }

            echo call_user_func($command);
        }
    }
290283
public function register_router_controller($router, $params, $controller)
    {
        if (!is_array($params)) {
            $params = array($params);
        }
        $route = $params[0];
        $method = isset($params[1]) ? $params[1] : 'GET|POST';
        $name = isset($params[2]) ? $params[2] : $controller;
        if (in_array($name, $this->controllers_routes)) {
            $name = null;
        } else {
            $this->controllers_routes[] = $name;
        }
        $this->controllers_url_routes[] = $controller . ' ' . $route . ' [' . $method . ']';
        if(!isset(self::$routes[$name])) {
            $router->map($method, $route, array($this, $controller), $name);
            self::$routes[$name] = true;
        } else {
            $router->map($method, $route, array($this, $controller));

        }
    }
1129137
public function createUrl(string $moduleName, string $controllerName, string $actionName, ?DataMap $params = null): string
    {
        $url = '/';
        if (! $this->isModuleName($moduleName)) {
            Application::$app->dispatchEvent(ApplicationErrorEvent::createCustom(500, '模块名' . $moduleName . '非法'));
        }
        if (! $this->isControllerName($controllerName)) {
            Application::$app->dispatchEvent(ApplicationErrorEvent::createCustom(500, '控制器名' . $controllerName . '非法'));
        }
        if (! $this->isActionName($actionName)) {
            Application::$app->dispatchEvent(ApplicationErrorEvent::createCustom(500, '操作名' . $actionName . '非法'));
        }
        return $url;
    }
892615
public static function to(?string $path = '/', ?int $code = null)
  {
    $redirect = new Redirect;
    $redirect->url = $path;

    if ($code !== null) {
      $redirect->code = $code;
      return $redirect->send();
    }

    return $redirect;
  }
888047
public function create($routeName, array $data = array(), array $query = array())
    {
        return $this->createUrl(parent::create($routeName, $data, $query));
    }