Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

rest_request.php
Go to the documentation of this file.
1 <?php
20 class ezpRestRequest extends ezcMvcRequest
21 {
27 public $get;
28
34 public $post;
35
41 public $originalProtocol;
42
48 public $contentVariables;
49
55 public $isEncrypted;
56
83 public function __construct( $date = null, $protocol = '',
84 $host = '', $uri = '', $requestId = '', $referrer = '',
85 $variables = array(), $get = array(), $post = array(),
86 $contentVariables = array(), $isEncrypted = false, $body = '',
87 $files = null, $accept = null, $agent = null, $authentication = null,
88 $raw = null, $cookies = array(), $isFatal = false, $originalProtocol = null )
89 {
90 $this->date = $date;
91 $this->protocol = $protocol;
92 $this->host = $host;
93 $this->uri = $uri;
94 $this->requestId = $requestId;
95 $this->referrer = $referrer;
96 $this->variables = $variables;
97 $this->get = $get;
98 $this->post = $post;
99 $this->contentVariables = $contentVariables;
100 $this->isEncrypted = $isEncrypted;
101 $this->body = $body;
102 $this->files = $files;
103 $this->accept = $accept;
104 $this->agent = $agent;
105 $this->authentication = $authentication;
106 $this->raw = $raw;
107 $this->cookies = $cookies;
108 $this->originalProtocol = ( $originalProtocol === null ? $protocol : $originalProtocol );
109 }
110
124 static public function __set_state( array $array )
125 {
126 return new ezpRestRequest( $array['date'], $array['protocol'],
127 $array['host'], $array['uri'], $array['requestId'],
128 $array['referrer'], $array['variables'], $array['get'],
129 $array['post'], $array['contentVariables'], $array['isEncrypted'],
130 $array['body'], $array['files'], $array['accept'], $array['agent'],
131 $array['authentication'], $array['raw'], $array['cookies'],
132 $array['isFatal'], $array['originalProtocol'] );
133 }
134
140 public function getBaseURI()
141 {
142 $hostUri = $this->getHostURI();
143 $apiName = ezpRestPrefixFilterInterface::getApiProviderName();
144 $apiPrefix = eZINI::instance( 'rest.ini' )->variable( 'System', 'ApiPrefix');
145 $uri = str_replace( $apiPrefix, $apiPrefix.'/'.$apiName, $this->uri );
146 $baseUri = $hostUri.$uri;
147
148 return $baseUri;
149 }
150
156 public function getHostURI()
157 {
158 $protIndex = strpos( $this->protocol, '-' );
159 $protocol = substr( $this->protocol, 0, $protIndex );
160 $hostUri = $protocol.'://'.$this->host;
161
162 return $hostUri;
163 }
164
171 public function getContentQueryString( $withQuestionMark = false )
172 {
173 $queryString = '';
174 $aParams = array();
175 foreach( $this->contentVariables as $name => $value )
176 {
177 if( $value !== null )
178 $aParams[] = $name.'='.$value;
179 }
180
181 if( !empty( $aParams ) )
182 {
183 $queryString = $withQuestionMark ? '?' : '';
184 $queryString .= implode( '&', $aParams );
185 }
186 return $queryString;
187 }
188
198 public function getParsedBody()
199 {
200 if ( $this->originalProtocol === 'http-post' )
201 {
202 if ( strpos( $this->raw['CONTENT_TYPE'], 'application/json' ) === 0 )
203 {
204 return json_decode( $this->body, true );
205 }
206 return $this->post;
207 }
208 if ( !isset( $this->raw['CONTENT_TYPE'] ) )
209 return null;
210
211 if ( empty( $this->body ) )
212 return array();
213
214 if ( strpos( $this->raw['CONTENT_TYPE'], 'application/x-www-form-urlencoded' ) === 0 )
215 {
216 parse_str( $this->body, $parsedBody );
217 return $parsedBody;
218 }
219 else if ( strpos( $this->raw['CONTENT_TYPE'], 'application/json' ) === 0 )
220 {
221 return json_decode( $this->body, true );
222 }
223 return null;
224 }
225 }
226 ?>
$uri
$uri
Definition: activate.php:71
$files
$files
Definition: articlepreview.php:91
$date
$date
Definition: bugpreview.php:66
ezpRestPrefixFilterInterface\getApiProviderName
static getApiProviderName()
Definition: prefix_filter.php:98
ezpRestRequest
Definition: rest_request.php:21
ezpRestRequest\getContentQueryString
getContentQueryString( $withQuestionMark=false)
Definition: rest_request.php:171
ezpRestRequest\$originalProtocol
$originalProtocol
Definition: rest_request.php:41
ezpRestRequest\__construct
__construct( $date=null, $protocol='', $host='', $uri='', $requestId='', $referrer='', $variables=array(), $get=array(), $post=array(), $contentVariables=array(), $isEncrypted=false, $body='', $files=null, $accept=null, $agent=null, $authentication=null, $raw=null, $cookies=array(), $isFatal=false, $originalProtocol=null)
Definition: rest_request.php:83
ezpRestRequest\$isEncrypted
$isEncrypted
Definition: rest_request.php:55
ezpRestRequest\$post
$post
Definition: rest_request.php:34
ezpRestRequest\__set_state
static __set_state(array $array)
Definition: rest_request.php:124
ezpRestRequest\$contentVariables
$contentVariables
Definition: rest_request.php:48
ezpRestRequest\getHostURI
getHostURI()
Definition: rest_request.php:156
ezpRestRequest\$get
$get
Definition: rest_request.php:27
ezpRestRequest\getBaseURI
getBaseURI()
Definition: rest_request.php:140
ezpRestRequest\getParsedBody
getParsedBody()
Definition: rest_request.php:198
$name
$name
Definition: companytypelist.php:194
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.