Redirects to a route.

@param Response $response
@param string   $route
@param array    $params

@return Response
359491
protected function redirect(Response $response, $route, array $params = [])
    {
        return $response->withRedirect($this->container['router']->pathFor($route, $params));
    }
64345
public function setSuccessRedirect(\Zend\Mvc\Controller\Plugin\Redirect $redirect, $route, $params = []) {
		$this->redirect = $redirect;
		$this->redirectRoute = $route;
		$this->params = $params;
	}
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);
    }
798716
public function redirect($route, $parameters = [], $status = 302)
    {
        return $this->application->redirect($this->path($route, $parameters), $status);
    }
435925
private function matchRoutes(Request $request, Response $response)
    {
        $stack  = [];
        $path   = $request->httpRequest->getPath();
        $method = $request->httpRequest->getMethod();

        foreach ($this->routes as $route) {
            if (!$route->match($path, $method)) {
                continue;
            }

            $methodArgs = $route->getArgs($path);
            $request->setData($methodArgs);

            $route->on('error', function (...$args) {
                $this->emit('error', $args);
            });

            $stack[] = function (...$params) use ($route) {
                $route->run(...$params);
            };
        }

        if (count($stack) == 0) {
            $this->emit('NotFound', array($request, $response));
            return;
        }

        $this->runStack($stack, $request, $response);
    }
154467
private static function treat(Route $route, $params)
    {
        // in case of get request or post request
        if (($route->getMethod() == 'post' && Request::isPost()) || ($route->getMethod() == 'get') || ($route->getMethod() == 'resource') || ($route->getMethod() == 'call')) {
            return static::execute($route, $params);
        }

        return false;
    }
497059
public static function render(ResponseInterface $response, $view, array $params = [])
    {
        return Application::getInstance()->view->render($response, $view, $params);
    }
1323918
public static function fromRoute(Route $route, array $params = []): self
    {
        $result = new self();
        $result->success = true;
        $result->route = $route;
        $result->matchedParams = $params;

        return $result;
    }
469071
public function run(Request $request, Response $response) : Response {

		$strict = $this->getParam('STRICT_ROUTING');
		$case = $this->getParam('CASE_SENSITIVE');
		$method = $request->getMethod();
		$url = $request->getUri()->getPath();

		//Matching
		foreach($this->routes as $route) {
			if($route->match($url, $strict, $case) && $method == $route->getMethod()) {
				return $route->call($request, $response);
			} elseif($route->match($url, $strict, $case) && $method == 'HEAD') {
				$body = $response->getBody();
				$body->close();
				$response = $response->withBody($body);
				return $response;
			}
		}

		//Error
		$methods = array();
		foreach($this->routes as $route) {
			array_push($methods, $route->getMethod());
			if($route->match($url, $strict, $case) && $method != $route->getMethod() && in_array($method, self::$_METHODS))
				return call_user_func($this->httpErrors['405'], $request, $response);

			elseif($route->match($url, $strict, $case) && $method != $route->getMethod() && !in_array($method, self::$_METHODS))
				return call_user_func($this->httpErrors['400'], $request, $response);
		}

		if(!in_array($method, $methods) && !in_array($method, self::$_METHODS))
			return call_user_func($this->httpErrors['400'], $request, $response);
		else
			return call_user_func($this->httpErrors['404'], $request, $response);
		
	}
338747
public function redirect($routeName, $controllerName = NULL, $params = [], $code = 302)
    {
        return new Redirect($routeName, $controllerName, $params, $code);
    }
336197
public function redirect($path, $replace = true, $http_response_code = null, $response = null)
    {
        if ($this->isSingle()) {
            UrlManager::redirect($path, $replace, $http_response_code, $response);
        }
    }
1000463
public function route($route, $parameters = [], $status = 302, $headers = [])
    {
        $path = $this->app->make('url')->route($route, $parameters);

        return $this->to($path, $status, $headers);
    }
144189
public function url($route, $params)
    {
        // use array filter to remove keys with null values
        $params += array_filter($this->getEmbedParams());

        return $this->router->generate($route, $params);
    }
272305
public function routeHref($route, $parameters = [], $target = '')
    {
        $href = route($route, $parameters);
        $href .= !empty($target) ? '#'.$target : '';
        return $this->href($href);
    }
857909
protected function other(Request $request, Response $response, Route $route)
    {
        $request;
        $response = $response->withStatus(500)
            ->withHeader('Content-Type', 'text/plain');
        $message = sprintf(
            'Route "%s" failed for rule "%s"',
            $route->name,
            $route->failedRule
        );
        $response->getBody()->write($message);
        return $response;
    }
442851
protected function _redirect(ServerRequest $request, Response $response) {
		$message = $request->getSession()->consume($this->_config['flashKey']);
		$url = $response->getHeader('Location')[0];
		$status = $response->getStatusCode();

		$json = JsonEncoder::encode([
			// Error and content are here to make the output the same as previously
			// with the component, so existing unit tests don't break.
			'error' => null,
			'content' => null,
			'_message' => $message,
			'_redirect' => compact('url', 'status'),
		], $this->_config['jsonOptions']);

		$response = $response->withStatus(200)
			->withoutHeader('Location')
			->withHeader('Content-Type', 'application/json; charset=' . $response->getCharset())
			->withStringBody($json);

		return $response;
	}
1114847
public function execute(Request $request, Response $response, ...$params)
    {
        if (defined('FOCUS_DEBUG') && FOCUS_DEBUG) {
            $this->getLogger()->debug('404 - Not Found');
        }

        $response->header('HTTP/1.1 404 Not Found');
        if (!empty($params)) {
            $response->write(...$params);
        } else {
            $response->write('Not Found.');
        }
    }