Neos\Flow\Http\Response::setStatus PHP Метод

setStatus() публичный Метод

Sets the HTTP status code and (optionally) a customized message.
public setStatus ( integer $code, string $message = null ) : Response
$code integer The status code
$message string If specified, this message is sent instead of the standard message
Результат Response This response, for method chaining
    public function setStatus($code, $message = null)
    {
        if (!is_int($code)) {
            throw new \InvalidArgumentException('The HTTP status code must be of type integer, ' . gettype($code) . ' given.', 1220526013);
        }
        if ($message === null) {
            $message = self::getStatusMessageByCode($code);
        }
        $this->statusCode = $code;
        $this->statusMessage = $message === null ? self::$statusMessages[$code] : $message;
        return $this;
    }

Usage Example

 /**
  * Sends the specified HTTP status immediately.
  *
  * NOTE: This method only supports web requests and will throw an exception if used with other request types.
  *
  * @param integer $statusCode The HTTP status code
  * @param string $statusMessage A custom HTTP status message
  * @param string $content Body content which further explains the status
  * @throws UnsupportedRequestTypeException If the request is not a web request
  * @throws StopActionException
  * @api
  */
 protected function throwStatus($statusCode, $statusMessage = null, $content = null)
 {
     $this->response->setStatus($statusCode, $statusMessage);
     if ($content === null) {
         $content = $this->response->getStatus();
     }
     $this->response->setContent($content);
     throw new StopActionException();
 }
All Usage Examples Of Neos\Flow\Http\Response::setStatus