Skip to content

Commit

Permalink
Merge pull request #2587 from atishamte/routes
Browse files Browse the repository at this point in the history
Better debug routes
  • Loading branch information
MGatner authored Feb 22, 2020
2 parents d0f6638 + 733bdd9 commit 84c261d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
14 changes: 7 additions & 7 deletions system/Commands/Utilities/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,24 @@ public function run(array $params)
{
$routes = $collection->getRoutes($method);

foreach ($routes as $from => $to)
foreach ($routes as $route => $handler)
{
// filter for strings, as callbacks aren't displayable
if (is_string($to))
if(is_string($handler))
{
$tbody[] = [
$from,
$method,
$to,
strtoupper($method),
$route,
$handler,
];
}
}
}

$thead = [
'Route',
'Method',
'Command',
'Route',
'Handler',
];

CLI::table($tbody, $thead);
Expand Down
37 changes: 29 additions & 8 deletions system/Debug/Toolbar/Collectors/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,38 @@ public function display(): array
];

/*
* Defined Routes
*/
$rawRoutes = $rawRoutes->getRoutes();
* Defined Routes
*/
$routes = [];
$methods = [
'get',
'head',
'post',
'patch',
'put',
'delete',
'options',
'trace',
'connect',
'cli',
];

foreach ($rawRoutes as $from => $to)
foreach ($methods as $method)
{
$routes[] = [
'from' => $from,
'to' => $to,
];
$raw = $rawRoutes->getRoutes($method);

foreach ($raw as $route => $handler)
{
// filter for strings, as callbacks aren't displayable
if (is_string($handler))
{
$routes[] = [
'method' => strtoupper($method),
'route' => $route,
'handler' => $handler,
];
}
}
}

return [
Expand Down
12 changes: 10 additions & 2 deletions system/Debug/Toolbar/Views/_routes.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,19 @@
<h3>Defined Routes</h3>

<table>
<thead>
<tr>
<th>Method</th>
<th>Route</th>
<th>Handler</th>
</tr>
</thead>
<tbody>
{routes}
<tr>
<td>{from}</td>
<td>{to}</td>
<td>{method}</td>
<td>{route}</td>
<td>{handler}</td>
</tr>
{/routes}
</tbody>
Expand Down

0 comments on commit 84c261d

Please sign in to comment.