[EventListener] Fix an issue with sub-requests

This commit is contained in:
Victor Berchet 2012-02-12 10:02:50 +01:00
parent 71bf279e9f
commit 3dd3d582c4
2 changed files with 7 additions and 3 deletions

View File

@ -66,7 +66,7 @@
<small>
- {{ collector.events.__section__.totaltime }} ms
{% if profile.parent %}
- <a href="{{ path('_profiler', { 'token': profile.parent.token }) }}?panel=time&threshold={{ threshold }}&width={{ width }}">parent</a>
- <a href="{{ path('_profiler', { 'token': profile.parent.token, 'panel': 'time', 'threshold': threshold, 'width': width }) }}">parent</a>
{% endif %}
</small>
</h3>
@ -79,7 +79,7 @@
{% for child in profile.children %}
{% set events = child.getcollector('time').events %}
<h3>
Sub-request "<a href="{{ path('_profiler', { 'token': child.token }) }}?panel=time&threshold={{ threshold }}&width={{ width }}">{{ child.getcollector('request').requestattributes.get('_controller') }}</a>"
Sub-request "<a href="{{ path('_profiler', { 'token': child.token, 'panel': 'time', 'threshold': threshold, 'width': width }) }}">{{ child.getcollector('request').requestattributes.get('_controller') }}</a>"
<small> - {{ events.__section__.totaltime }} ms</small>
</h3>

View File

@ -102,7 +102,11 @@ class ProfilerListener implements EventSubscriberInterface
// keep the profile as the child of its parent
if (!$master) {
array_pop($this->requests);
$this->children[end($this->requests)][] = $profile;
$parent = end($this->requests);
$profiles = isset($this->children[$parent]) ? $this->children[$parent] : array();
$profiles[] = $profile;
$this->children[$parent] = $profiles;
}
// store the profile and its children