Skip to content

Commit

Permalink
Merge pull request #478 from tystr/typehinted-controller-arg-route-fix
Browse files Browse the repository at this point in the history
Revert the changes to how typehinted controller arguments are handled when using automatic route generation
  • Loading branch information
lsmith77 committed Jun 17, 2013
2 parents 6e11a63 + 030669f commit a1b45da
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Routing/Loader/Reader/RestActionReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private function getHttpMethodAndResourcesFromMethod(\ReflectionMethod $method,
}

/**
* Returns readable arguments from method. Typehinted arguments are ignored.
* Returns readable arguments from method.
*
* @param \ReflectionMethod $method
*
Expand All @@ -281,12 +281,29 @@ private function getMethodArguments(\ReflectionMethod $method)
// ignore all query params
$params = $this->paramReader->getParamsFromMethod($method);

// ignore type hinted arguments that are or extend from:
// * Symfony\Component\HttpFoundation\Request
// * FOS\RestBundle\Request\QueryFetcher
$ignoreClasses = array(
'Symfony\Component\HttpFoundation\Request',
'FOS\RestBundle\Request\ParamFetcherInterface',
);

$arguments = array();
foreach ($method->getParameters() as $argument) {
if (isset($params[$argument->getName()]) || null !== $argument->getClass()) {
if (isset($params[$argument->getName()])) {
continue;
}

$argumentClass = $argument->getClass();
if ($argumentClass) {
foreach ($ignoreClasses as $class) {
if ($argumentClass->getName() === $class || $argumentClass->isSubclassOf($class)) {
continue 2;
}
}
}

$arguments[] = $argument;
}

Expand Down

0 comments on commit a1b45da

Please sign in to comment.