Skip to content

Commit

Permalink
[HttpKernel] Collect data if the controller is a Closure
Browse files Browse the repository at this point in the history
Use the same format as object methods to describe closures and collect
the file and the line where it's been declared.

These informations should be added in the views of the webprofiler.
  • Loading branch information
GromNaN committed Mar 13, 2013
1 parent 2453a58 commit cce3a6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -133,7 +133,13 @@ public function collect(Request $request, Response $response, \Exception $except
}
}
} elseif ($controller instanceof \Closure) {
$this->data['controller'] = 'Closure';
$r = new \ReflectionFunction($controller);
$this->data['controller'] = array(
'class' => $r->getName(),
'method' => null,
'file' => $r->getFilename(),
'line' => $r->getStartLine(),
);
} else {
$this->data['controller'] = (string) $controller ?: 'n/a';
}
Expand Down
Expand Up @@ -81,7 +81,12 @@ public function testControllerInspection(Request $request, Response $response)
array(
'Closure',
function() { return 'foo'; },
'Closure',
array(
'class' => __NAMESPACE__ . '\{closure}',
'method' => null,
'file' => __FILE__,
'line' => __LINE__ - 5,
),
),

array(
Expand Down

0 comments on commit cce3a6b

Please sign in to comment.