Skip to content

Commit 2503a74

Browse files
committed
Merge pull request #110 from Phennim/master
Add HTTP PATCH request method
2 parents 2ef155c + 02e3f0d commit 2503a74

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/request/sfRequest.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ abstract class sfRequest implements ArrayAccess
2525
const GET = 'GET';
2626
const POST = 'POST';
2727
const PUT = 'PUT';
28+
const PATCH = 'PATCH';
2829
const DELETE = 'DELETE';
2930
const HEAD = 'HEAD';
3031
const OPTIONS = 'OPTIONS';
@@ -148,7 +149,7 @@ public function getMethod()
148149
*/
149150
public function setMethod($method)
150151
{
151-
if (!in_array(strtoupper($method), array(self::GET, self::POST, self::PUT, self::DELETE, self::HEAD, self::OPTIONS)))
152+
if (!in_array(strtoupper($method), array(self::GET, self::POST, self::PUT, self::PATCH, self::DELETE, self::HEAD, self::OPTIONS)))
152153
{
153154
throw new sfException(sprintf('Invalid request method: %s.', $method));
154155
}

lib/request/sfWebRequest.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ public function initialize(sfEventDispatcher $dispatcher, $parameters = array(),
114114
}
115115
break;
116116

117+
case 'PATCH':
118+
$this->setMethod(self::PATCH);
119+
if ('application/x-www-form-urlencoded' === $this->getContentType())
120+
{
121+
parse_str($this->getContent(), $postParameters);
122+
}
123+
break;
124+
117125
case 'DELETE':
118126
$this->setMethod(self::DELETE);
119127
if ('application/x-www-form-urlencoded' === $this->getContentType())

0 commit comments

Comments
 (0)