[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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$request = $event->getRequest();
|
||||||
$exception = $this->exception;
|
$exception = $this->exception;
|
||||||
$this->exception = null;
|
$this->exception = null;
|
||||||
|
|
||||||
if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) {
|
if (null !== $this->matcher && !$this->matcher->matches($request)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$profile = $this->profiler->collect($event->getRequest(), $event->getResponse(), $exception)) {
|
if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep the profile as the child of its parent
|
// keep the profile as the child of its parent
|
||||||
if (!$master) {
|
if (!$master) {
|
||||||
array_pop($this->requests);
|
array_pop($this->requests);
|
||||||
|
$this->children[end($this->requests)][] = $profile;
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the profile and its children
|
// store the profile and its children
|
||||||
if (isset($this->children[$event->getRequest()])) {
|
if (isset($this->children[$request])) {
|
||||||
foreach ($this->children[$event->getRequest()] as $child) {
|
foreach ($this->children[$request] as $child) {
|
||||||
$child->setParent($profile);
|
$child->setParent($profile);
|
||||||
$profile->addChild($child);
|
$profile->addChild($child);
|
||||||
$this->profiler->saveProfile($child);
|
$this->profiler->saveProfile($child);
|
||||||
}
|
}
|
||||||
$this->children[$event->getRequest()] = array();
|
$this->children[$request] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->profiler->saveProfile($profile);
|
$this->profiler->saveProfile($profile);
|
||||||
|
@ -157,7 +157,7 @@ class Profiler
|
|||||||
* @param Response $response A Response instance
|
* @param Response $response A Response instance
|
||||||
* @param \Exception $exception An exception instance if the request threw one
|
* @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)
|
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user