Skip to content

Commit 71f2ed7

Browse files
committed
Merge pull request #941 from FriendsOfSymfony/options_route_generation
fixed handling of OPTIONS in route generation
2 parents 1385afd + e0ab177 commit 71f2ed7

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Routing/Loader/Reader/RestActionReader.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ private function getHttpMethodAndResourcesFromMethod(\ReflectionMethod $method,
307307
$isInflectable = ($resourcePluralized != $resource[count($resource) - 1]);
308308
$resource[count($resource)-1] = $resourcePluralized;
309309
}
310+
} elseif ('options' === $httpMethod && !empty($resource) && 's' === substr($method->getName(), -1)) {
311+
$resource[count($resource)-1] = $this->inflector->pluralize(end($resource));
310312
}
311313

312314
$resources = array_merge($resource, $resources);

Tests/Fixtures/Controller/ArticleController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
class ArticleController extends FosRestController implements ClassResourceInterface
1919
{
20-
public function optionsAction()
21-
{} // [OPTION] /articles
20+
public function optionsActions()
21+
{} // [OPTIONS] /articles
2222

2323
public function cgetAction()
2424
{} // [GET] /articles

Tests/Fixtures/Etalon/resource_controller.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
options_articles:
2+
method: OPTIONS
3+
pattern: /articles.{_format}
4+
controller: ::optionsAction
5+
16
get_articles:
27
method: GET
38
pattern: /articles.{_format}

0 commit comments

Comments
 (0)