/** * @param Request $httpRequest * @param RedirectInterface $redirect * @return Response|null */ protected function buildResponse(Request $httpRequest, RedirectInterface $redirect) { if (headers_sent() === true && FLOW_SAPITYPE !== 'CLI') { return null; } $response = new Response(); $statusCode = $redirect->getStatusCode(); $response->setStatus($statusCode); if ($statusCode >= 300 && $statusCode <= 399) { $location = $redirect->getTargetUriPath(); if (parse_url($location, PHP_URL_SCHEME) === null) { $location = $httpRequest->getBaseUri() . $location; } $response->setHeaders(new Headers(['Location' => $location, 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'Expires' => 'Sat, 26 Jul 1997 05:00:00 GMT'])); } elseif ($statusCode >= 400 && $statusCode <= 599) { $exception = new Exception(); $exception->setStatusCode($statusCode); throw $exception; } return $response; }
/** * @param RedirectInterface $redirect * @return RedirectInterface */ public static function create(RedirectInterface $redirect) { return new self($redirect->getSourceUriPath(), $redirect->getTargetUriPath(), $redirect->getStatusCode(), $redirect->getHost()); }
/** * @param string $prefix * @param RedirectInterface $redirect * @return void */ protected function outputRedirectLine($prefix, RedirectInterface $redirect) { $this->outputLine(' %s %s <info>=></info> %s <comment>(%d)</comment> - %s', [$prefix, $redirect->getSourceUriPath(), $redirect->getTargetUriPath(), $redirect->getStatusCode(), $redirect->getHost() ?: 'all host']); }