Skip to content

Commit 721c1af

Browse files
committed
fixed handling of optionsAction() handling in route generation
1 parent 567e518 commit 721c1af

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Routing/Loader/Reader/RestActionReader.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,14 @@ private function getHttpMethodAndResourcesFromMethod(\ReflectionMethod $method,
302302
) {
303303
$isCollection = true;
304304
$httpMethod = substr($httpMethod, 1);
305-
if (!empty($resource)) {
306-
$resourcePluralized = $this->inflector->pluralize(end($resource));
307-
$isInflectable = ($resourcePluralized != $resource[count($resource) - 1]);
308-
$resource[count($resource)-1] = $resourcePluralized;
309-
}
310-
} elseif ('options' === $httpMethod && !empty($resource) && 's' === substr($method->getName(), -1)) {
311-
$resource[count($resource)-1] = $this->inflector->pluralize(end($resource));
305+
} elseif ('options' === $httpMethod) {
306+
$isCollection = true;
307+
}
308+
309+
if ($isCollection && !empty($resource)) {
310+
$resourcePluralized = $this->inflector->pluralize(end($resource));
311+
$isInflectable = ($resourcePluralized != $resource[count($resource) - 1]);
312+
$resource[count($resource)-1] = $resourcePluralized;
312313
}
313314

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

Tests/Fixtures/Controller/ArticleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

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

2323
public function cgetAction()

0 commit comments

Comments
 (0)