Skip to content

Commit

Permalink
Updated route data collector
Browse files Browse the repository at this point in the history
  • Loading branch information
simba77 committed Feb 10, 2024
1 parent cc154dc commit 9bfbd8c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions system/src/Debug/Collectors/RouteDataCollector.php
Expand Up @@ -6,7 +6,6 @@

use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use ReflectionClass;
use Throwable;

class RouteDataCollector extends DataCollector implements Renderable
Expand All @@ -17,18 +16,11 @@ public function collect(): array
$route = di('route');
$formatter = $this->getDataFormatter();

$reflection = new ReflectionClass($route);
$handler = $reflection->getProperty('handler');
$handler->setAccessible(true);
$controller = $handler->getValue($route);

return [
'Route name' => $route->getName(),
'Method' => $route->getMethod(),
'Path' => $route->getPath($route->getVars()),
'Vars' => $formatter->formatVar($route->getVars()),
'Controller' => (is_array($controller) && count($controller) === 2 ? implode('::', $controller) : $formatter->formatVar($controller)),
'Middlewares' => $formatter->formatVar($route->getMiddlewareStack()),
'Route name' => $route['_name'],
'Vars' => $formatter->formatVar($route),
'Controller' => (is_array($route['_controller']) && count($route['_controller']) === 2 ? implode('::', $route['_controller']) : $formatter->formatVar($route['_controller'])),
'Middlewares' => $formatter->formatVar($route['_middlewares']),
];
} catch (Throwable) {
return [];
Expand Down

0 comments on commit 9bfbd8c

Please sign in to comment.