Skip to content

Commit

Permalink
Merge pull request #949 from FriendsOfSymfony/fix_options_handling
Browse files Browse the repository at this point in the history
fixed handling of optionsAction() handling in route generation
  • Loading branch information
lsmith77 committed Jan 26, 2015
2 parents 567e518 + 721c1af commit a47ed99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions Routing/Loader/Reader/RestActionReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,14 @@ private function getHttpMethodAndResourcesFromMethod(\ReflectionMethod $method,
) {
$isCollection = true;
$httpMethod = substr($httpMethod, 1);
if (!empty($resource)) {
$resourcePluralized = $this->inflector->pluralize(end($resource));
$isInflectable = ($resourcePluralized != $resource[count($resource) - 1]);
$resource[count($resource)-1] = $resourcePluralized;
}
} elseif ('options' === $httpMethod && !empty($resource) && 's' === substr($method->getName(), -1)) {
$resource[count($resource)-1] = $this->inflector->pluralize(end($resource));
} elseif ('options' === $httpMethod) {
$isCollection = true;
}

if ($isCollection && !empty($resource)) {
$resourcePluralized = $this->inflector->pluralize(end($resource));
$isInflectable = ($resourcePluralized != $resource[count($resource) - 1]);
$resource[count($resource)-1] = $resourcePluralized;
}

$resources = array_merge($resource, $resources);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class ArticleController extends FosRestController implements ClassResourceInterface
{
public function optionsActions()
public function optionsAction()
{} // [OPTIONS] /articles

public function cgetAction()
Expand Down

0 comments on commit a47ed99

Please sign in to comment.