[HttpKernel] Tweak the code of the ProfilerListener
This commit is contained in:
parent
ce5cdaddea
commit
814876fb12
@ -87,40 +87,32 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$request = $event->getRequest();
|
||||
$exception = $this->exception;
|
||||
$this->exception = null;
|
||||
|
||||
if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) {
|
||||
if (null !== $this->matcher && !$this->matcher->matches($request)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$profile = $this->profiler->collect($event->getRequest(), $event->getResponse(), $exception)) {
|
||||
if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// keep the profile as the child of its parent
|
||||
if (!$master) {
|
||||
array_pop($this->requests);
|
||||
|
||||
$parent = $this->requests[count($this->requests) - 1];
|
||||
if (!isset($this->children[$parent])) {
|
||||
$profiles = array($profile);
|
||||
} else {
|
||||
$profiles = $this->children[$parent];
|
||||
$profiles[] = $profile;
|
||||
}
|
||||
|
||||
$this->children[$parent] = $profiles;
|
||||
$this->children[end($this->requests)][] = $profile;
|
||||
}
|
||||
|
||||
// store the profile and its children
|
||||
if (isset($this->children[$event->getRequest()])) {
|
||||
foreach ($this->children[$event->getRequest()] as $child) {
|
||||
if (isset($this->children[$request])) {
|
||||
foreach ($this->children[$request] as $child) {
|
||||
$child->setParent($profile);
|
||||
$profile->addChild($child);
|
||||
$this->profiler->saveProfile($child);
|
||||
}
|
||||
$this->children[$event->getRequest()] = array();
|
||||
$this->children[$request] = array();
|
||||
}
|
||||
|
||||
$this->profiler->saveProfile($profile);
|
||||
|
@ -157,7 +157,7 @@ class Profiler
|
||||
* @param Response $response A Response instance
|
||||
* @param \Exception $exception An exception instance if the request threw one
|
||||
*
|
||||
* @return Profile|false A Profile instance or false if the profiler is disabled
|
||||
* @return Profile|null A Profile instance or false if the profiler is disabled
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user