[HttpKernel] Collect data if the controller is a Closure
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.
This commit is contained in:
parent
2453a58d56
commit
cce3a6bfca
@ -133,7 +133,13 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($controller instanceof \Closure) {
|
} 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 {
|
} else {
|
||||||
$this->data['controller'] = (string) $controller ?: 'n/a';
|
$this->data['controller'] = (string) $controller ?: 'n/a';
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,12 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(
|
array(
|
||||||
'Closure',
|
'Closure',
|
||||||
function() { return 'foo'; },
|
function() { return 'foo'; },
|
||||||
'Closure',
|
array(
|
||||||
|
'class' => __NAMESPACE__ . '\{closure}',
|
||||||
|
'method' => null,
|
||||||
|
'file' => __FILE__,
|
||||||
|
'line' => __LINE__ - 5,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
|
Reference in New Issue
Block a user