コード例 #1
0
 /**
  * @return int
  */
 public function getStatusCode()
 {
     if (isset($this->exception)) {
         return $this->getExceptionStatusCode();
     } elseif (isset($this->redirect)) {
         return $this->redirect->getStatusCode();
     } elseif ($this->isEmpty()) {
         return Response::HTTP_NO_CONTENT;
     }
     return $this->statusCode;
 }
コード例 #2
0
 /**
  * Copies an existing redirect response into a safe one.
  *
  * The safe one cannot accidentally redirect to an external URL, unless
  * actively wanted (see TrustedRedirectResponse).
  *
  * @param \Symfony\Component\HttpFoundation\RedirectResponse $response
  *   The original redirect.
  *
  * @return static
  */
 public static function createFromRedirectResponse(RedirectResponse $response)
 {
     $safe_response = new static($response->getTargetUrl(), $response->getStatusCode(), $response->headers->allPreserveCase());
     $safe_response->setProtocolVersion($response->getProtocolVersion());
     $safe_response->setCharset($response->getCharset());
     return $safe_response;
 }