mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Sort equal routes by HTTP method
This commit is contained in:
parent
8426a3a70e
commit
e2af9b3fc4
@ -69,12 +69,21 @@ class ApiDocExtractor
|
||||
}
|
||||
}
|
||||
|
||||
usort($array, function($a, $b) {
|
||||
$methodOrder = array('GET', 'POST', 'PUT', 'DELETE');
|
||||
|
||||
usort($array, function($a, $b) use ($methodOrder) {
|
||||
if ($a['resource'] === $b['resource']) {
|
||||
if ($a['route']->getPattern() === $b['route']->getPattern()) {
|
||||
$methodA = array_search($a['route']->getRequirement('_method'), $methodOrder);
|
||||
$methodB = array_search($b['route']->getRequirement('_method'), $methodOrder);
|
||||
|
||||
if ($methodA === $methodB) {
|
||||
return strcmp($a['route']->getRequirement('_method'), $b['route']->getRequirement('_method'));
|
||||
}
|
||||
|
||||
return $methodA > $methodB ? 1 : -1;
|
||||
}
|
||||
|
||||
return strcmp($a['route']->getPattern(), $b['route']->getPattern());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user