forked from ahmadnassri/restful-zend-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRequest.php
executable file
·46 lines (37 loc) · 1.01 KB
/
Request.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
class REST_Request extends Zend_Controller_Request_Http
{
private $_error = false;
public function setError($code, $message)
{
$this->_error = new stdClass;
$this->_error->code = $code;
$this->_error->message = $message;
return $this;
}
public function getError()
{
return $this->_error;
}
public function hasError()
{
return $this->_error !== false;
}
public function getMethod()
{
if ($this->getParam('_method', false)) {
return strtoupper($this->getParam('_method'));
}
if ($this->getHeader('X-HTTP-Method-Override')) {
return strtoupper($this->getHeader('X-HTTP-Method-Override'));
}
return $this->getServer('REQUEST_METHOD');
}
public function dispatchError($code, $message)
{
$this->setError($code, $message);
$this->setControllerName('error');
$this->setActionName('error');
$this->setDispatched(true);
}
}