Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
0f6956d1
Commit
0f6956d1
authored
Jan 27, 2014
by
Ben Ramsey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provides support for the PATCH method for HTTP
http://tools.ietf.org/html/rfc5789
parent
a793aa89
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
0 deletions
+34
-0
src/Silex/Application.php
src/Silex/Application.php
+13
-0
src/Silex/ControllerCollection.php
src/Silex/ControllerCollection.php
+13
-0
tests/Silex/Tests/ApplicationTest.php
tests/Silex/Tests/ApplicationTest.php
+3
-0
tests/Silex/Tests/RouterTest.php
tests/Silex/Tests/RouterTest.php
+5
-0
No files found.
src/Silex/Application.php
View file @
0f6956d1
...
...
@@ -259,6 +259,19 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
return
$this
[
'controllers'
]
->
delete
(
$pattern
,
$to
);
}
/**
* Maps a PATCH request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
*
* @return Controller
*/
public
function
patch
(
$pattern
,
$to
=
null
)
{
return
$this
[
'controllers'
]
->
patch
(
$pattern
,
$to
);
}
/**
* Adds an event listener that listens on the specified events.
*
...
...
src/Silex/ControllerCollection.php
View file @
0f6956d1
...
...
@@ -127,6 +127,19 @@ class ControllerCollection
return
$this
->
match
(
$pattern
,
$to
)
->
method
(
'DELETE'
);
}
/**
* Maps a PATCH request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
*
* @return Controller
*/
public
function
patch
(
$pattern
,
$to
=
null
)
{
return
$this
->
match
(
$pattern
,
$to
)
->
method
(
'PATCH'
);
}
public
function
__call
(
$method
,
$arguments
)
{
if
(
!
method_exists
(
$this
->
defaultRoute
,
$method
))
{
...
...
tests/Silex/Tests/ApplicationTest.php
View file @
0f6956d1
...
...
@@ -46,6 +46,9 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$returnValue
=
$app
->
put
(
'/foo'
,
function
()
{});
$this
->
assertInstanceOf
(
'Silex\Controller'
,
$returnValue
);
$returnValue
=
$app
->
patch
(
'/foo'
,
function
()
{});
$this
->
assertInstanceOf
(
'Silex\Controller'
,
$returnValue
);
$returnValue
=
$app
->
delete
(
'/foo'
,
function
()
{});
$this
->
assertInstanceOf
(
'Silex\Controller'
,
$returnValue
);
}
...
...
tests/Silex/Tests/RouterTest.php
View file @
0f6956d1
...
...
@@ -130,6 +130,10 @@ class RouterTest extends \PHPUnit_Framework_TestCase
return
'put resource'
;
});
$app
->
patch
(
'/resource'
,
function
()
{
return
'patch resource'
;
});
$app
->
delete
(
'/resource'
,
function
()
{
return
'delete resource'
;
});
...
...
@@ -140,6 +144,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
$this
->
checkRouteResponse
(
$app
,
'/resource'
,
'get resource'
);
$this
->
checkRouteResponse
(
$app
,
'/resource'
,
'post resource'
,
'post'
);
$this
->
checkRouteResponse
(
$app
,
'/resource'
,
'put resource'
,
'put'
);
$this
->
checkRouteResponse
(
$app
,
'/resource'
,
'patch resource'
,
'patch'
);
$this
->
checkRouteResponse
(
$app
,
'/resource'
,
'delete resource'
,
'delete'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment