Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

response.php
Go to the documentation of this file.
1 <?php
12 class ezpRestStatusResponse implements ezcMvcResultStatusObject
13 {
19 public $code;
20
26 public $message;
27
33 public $headers;
34
40 public static $statusCodes = array(
41 200 => "OK",
42 201 => "Created",
43 202 => "Accepted",
44 203 => "Non-Authoritative Information",
45 204 => "No Content",
46 205 => "Reset Content",
47 206 => "Partial Content",
48 300 => "Multiple Choices",
49 301 => "Moved Permanently",
50 302 => "Found",
51 303 => "See Other",
52 304 => "Not Modified",
53 305 => "Use Proxy",
54 307 => "Temporary Redirect",
55 400 => "Bad Request",
56 401 => "Unauthorized",
57 402 => "Payment Required",
58 403 => "Forbidden",
59 404 => "Not Found",
60 405 => "Method Not Allowed",
61 406 => "Not Acceptable",
62 409 => "Conflict",
63 410 => "Gone",
64 411 => "Length Required",
65 412 => "Precondition Failed",
66 413 => "Request Entity Too Large",
67 415 => "Unsupported Media Type",
68 500 => "Internal Server Error",
69 501 => "Not Implemented",
70 503 => "Service Unavailable",
71 );
72
80 public function __construct( $code = null, $message = null, array $headers = array() )
81 {
82 $this->code = $code;
83 $this->message = $message;
84 $this->headers = $headers;
85 }
86
96 public function process( ezcMvcResponseWriter $writer )
97 {
98 if ( $writer instanceof ezcMvcHttpResponseWriter )
99 {
100 $writer->headers["HTTP/1.1 " . $this->code] = self::$statusCodes[$this->code];
101 $writer->headers = $this->headers + $writer->headers;
102 }
103
104 if ( $this->message !== null )
105 {
106 $writer->headers['Content-Type'] = 'application/json; charset=UTF-8';
107 $writer->response->body = json_encode( $this->message );
108 }
109 }
110 }
ezpRestStatusResponse
Definition: response.php:13
ezpRestStatusResponse\$statusCodes
static $statusCodes
Definition: response.php:40
ezpRestStatusResponse\__construct
__construct( $code=null, $message=null, array $headers=array())
Definition: response.php:80
ezpRestStatusResponse\$message
$message
Definition: response.php:26
ezpRestStatusResponse\$code
$code
Definition: response.php:19
ezpRestStatusResponse\process
process(ezcMvcResponseWriter $writer)
Definition: response.php:96
ezpRestStatusResponse\$headers
$headers
Definition: response.php:33
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.