示例#1
0
 /**
  * creates a redirect response conforming to the rules defined for a redirect status code
  * The URL to redirect to should be a full URL, with schema etc.
  *
  * @param string  $url
  * @param integer $status
  * @param array   $headers
  * 
  * @throws \InvalidArgumentException
  */
 public function __construct($url, $status = Response::HTTP_FOUND, $headers = [])
 {
     parent::__construct('', $status, $headers);
     $this->setTargetUrl($url);
     if (!$this->isRedirect()) {
         throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status));
     }
 }
示例#2
0
 /**
  * generate error and (optional) error page content
  *
  * @param integer $errorCode
  */
 protected function generateHttpError($errorCode = 404)
 {
     $content = '<h1>' . $errorCode . ' ' . Response::$statusTexts[$errorCode] . '</h1>';
     Response::create($content, $errorCode)->send();
     exit;
 }