Skip to content

Commit 4757554

Browse files
committed
Tweak route collector
fixes barryvdh#243
1 parent 0fddfb1 commit 4757554

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

src/DataCollector/IlluminateRouteCollector.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(Router $router)
3333
*/
3434
public function collect()
3535
{
36-
$route = \Route::current();
36+
$route = $this->router->current();
3737
return $this->getRouteInformation($route);
3838
}
3939

@@ -49,15 +49,31 @@ protected function getRouteInformation($route)
4949
return array();
5050
}
5151
$uri = head($route->methods()) . ' ' . $route->uri();
52-
53-
return array(
54-
'host' => $route->domain() ?: '-',
55-
'uri' => $uri ?: '-',
56-
'name' => $route->getName() ?: '-',
57-
'action' => $route->getActionName() ?: '-',
58-
'before' => $this->getBeforeFilters($route) ?: '-',
59-
'after' => $this->getAfterFilters($route) ?: '-'
52+
$action = $route->getAction();
53+
54+
$result = array(
55+
'uri' => $uri ?: '-',
6056
);
57+
58+
$result = array_merge($result, $action);
59+
60+
if (isset($action['controller']) && strpos($action['controller'], '@') !== false) {
61+
list($controller) = explode('@', $action['controller']);
62+
if(class_exists($controller)) {
63+
$reflector = new \ReflectionClass($controller);
64+
$result['file'] = $reflector->getFileName();
65+
}
66+
}
67+
68+
if ($before = $this->getBeforeFilters($route)) {
69+
$result['before'] = $before;
70+
}
71+
72+
if ($after = $this->getAfterFilters($route)) {
73+
$result['after'] = $after;
74+
}
75+
76+
return $result;
6177
}
6278

6379
/**

0 commit comments

Comments
 (0)