Skip to content
Permalink
Browse files

accept array of "_method"s on route::match()

  • Loading branch information...
saeideng committed Nov 28, 2017
1 parent c159efc commit 53b71ce27f7c65fa1a4352b5fda5901cf056c6e0
Showing with 13 additions and 3 deletions.
  1. +6 −3 src/Routing/Route/Route.php
  2. +7 −0 tests/TestCase/Routing/Route/RouteTest.php
@@ -741,11 +741,14 @@ protected function _matchMethod($url)
if (empty($url['_method'])) {
return false;
}
if (!in_array(strtoupper($url['_method']), (array)$this->defaults['_method'])) {
return false;
$methods = array_map('strtoupper', (array)$url['_method']);
foreach ($methods as $value) {
if (in_array($value, (array)$this->defaults['_method'])) {
return true;
}
}
return true;
return false;
}
/**
@@ -1199,6 +1199,13 @@ public function testMatchWithMultipleHttpMethodConditions()
'_method' => 'POST',
];
$this->assertEquals('/sample', $route->match($url));
$url = [
'controller' => 'posts',
'action' => 'index',
'_method' => ['PUT', 'POST'],
];
$this->assertEquals('/sample', $route->match($url));
}
/**

0 comments on commit 53b71ce

Please sign in to comment.
You can’t perform that action at this time.