/** * Redirects the web request to another uri. * * NOTE: This method only supports web requests and will throw an exception if used with other request types. * * @param mixed $uri Either a string representation of a URI or a \F3\FLOW3\Property\DataType\Uri object * @param integer $delay (optional) The delay in seconds. Default is no delay. * @param integer $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other" * @throws \F3\FLOW3\MVC\Exception\UnsupportedRequestTypeException If the request is not a web request * @throws \F3\FLOW3\MVC\Exception\StopActionException * @author Robert Lemke <*****@*****.**> * @api */ protected function redirectToUri($uri, $delay = 0, $statusCode = 303) { if (!$this->request instanceof \F3\FLOW3\MVC\Web\Request) { throw new \F3\FLOW3\MVC\Exception\UnsupportedRequestTypeException('redirect() only supports web requests.', 1220539734); } $uri = $this->request->getBaseUri() . (string) $uri; $escapedUri = htmlentities($uri, ENT_QUOTES, 'utf-8'); $this->response->setContent('<html><head><meta http-equiv="refresh" content="' . intval($delay) . ';url=' . $escapedUri . '"/></head></html>'); $this->response->setStatus($statusCode); $this->response->setHeader('Location', (string) $uri); throw new \F3\FLOW3\MVC\Exception\StopActionException(); }
/** * Starts the authentication: Redirect to login page * * @param \F3\FLOW3\MVC\RequestInterface $request The current request * @param \F3\FLOW3\MVC\ResponseInterface $response The current response * @return void */ public function startAuthentication(\F3\FLOW3\MVC\RequestInterface $request, \F3\FLOW3\MVC\ResponseInterface $response) { if (!$this->canForward($request)) { throw new \F3\FLOW3\Security\Exception\RequestTypeNotSupportedException('Unsupported request type for authentication entry point given.', 1237282462); } if (!is_array($this->options) || !isset($this->options['uri'])) { throw new \F3\FLOW3\Security\Exception\MissingConfigurationException('The configuration for the WebRedirect authentication entry point is incorrect or missing.', 1237282583); } $escapedUri = htmlentities($this->options['uri'], ENT_QUOTES, 'utf-8'); $response->setContent('<html><head><meta http-equiv="refresh" content="0;url=' . $escapedUri . '"/></head></html>'); $response->setStatus(303); $response->setHeader('Location', (string) $this->options['uri']); }