-
-
Save Bendihossan/bd08ec2488eb816c561d to your computer and use it in GitHub Desktop.
Suggested modification to generateRouteName() function from RestActionReader.php (FosRestBundle) to fix a bug.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generates route name from resources list. | |
* | |
* @param array $resources | |
* @param \ReflectionMethod $method | |
* | |
* @return string | |
*/ | |
private function generateRouteName(array $resources, \ReflectionMethod $method) | |
{ | |
$routeName = ''; | |
foreach ($resources as $resource) { | |
if (null !== $resource) { | |
// Checks if the resource is an uncountable word and if the method call is a collection get action. | |
if ($method->name == 'cgetAction' | |
&& true == in_array(strtolower($resource), Pluralization::$uncountables) | |
) { | |
// If both are true then we add '_collection' to the route name to | |
// avoid a potential duplicate with the get action for a single resource. | |
$routeName .= '_collection'; | |
} | |
$routeName .= '_' . basename($resource); | |
} | |
} | |
return $routeName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment