From 20bd30cd7054e73e4763db7f22f214b89bd963a4 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Sat, 20 Aug 2022 18:41:31 -0300 Subject: [PATCH] Show routes in the order they are set --- src/Debug/RoutingCollector.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Debug/RoutingCollector.php b/src/Debug/RoutingCollector.php index c59530f..3c9b53f 100644 --- a/src/Debug/RoutingCollector.php +++ b/src/Debug/RoutingCollector.php @@ -240,6 +240,7 @@ protected function renderRouteCollectionsTable(RouteCollection $collection) : st + @@ -248,8 +249,9 @@ protected function renderRouteCollectionsTable(RouteCollection $collection) : st - getRoutes($collection) as $route): ?> + getRoutes($collection) as $index => $route): ?> > + @@ -271,7 +273,9 @@ protected function renderRouteCollectionsTable(RouteCollection $collection) : st protected function getRoutes(RouteCollection $collection) : array { $result = []; - foreach ($collection->routes as $method => $routes) { + $collectionRoutes = $collection->routes; + \ksort($collectionRoutes); + foreach ($collectionRoutes as $method => $routes) { foreach ($routes as $route) { $result[] = [ 'method' => $method, @@ -283,13 +287,6 @@ protected function getRoutes(RouteCollection $collection) : array ]; } } - \usort($result, static function ($str1, $str2) { - $cmp = \strcmp($str1['path'], $str2['path']); - if ($cmp === 0) { - $cmp = \strcmp($str1['method'], $str2['method']); - } - return $cmp; - }); return $result; }
# Method Path Action
toCodeBrackets(\htmlentities($route['path'])) ?>