Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b27c2f

Browse files
committed
feature #26650 [Messenger] Clone messages to show in profiler (Nyholm)
This PR was squashed before being merged into the 4.1-dev branch (closes #26650). Discussion ---------- [Messenger] Clone messages to show in profiler | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | na | License | MIT | Doc PR | na We should make the profiler page more pretty by using the cloner. ![screen shot 2018-03-23 at 11 08 02](https://user-images.githubusercontent.com/1275206/37823687-816a373a-2e8a-11e8-824e-ac7f96a51e3b.png) Commits ------- 4d1be87 [Messenger] Clone messages to show in profiler
2 parents 7b20b8c + 4d1be87 commit 5b27c2f

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

src/Symfony/Bundle/FrameworkBundle/DataCollector/MessengerDataCollector.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function handle($message, callable $next)
5353
$debugRepresentation = array(
5454
'message' => array(
5555
'type' => get_class($message),
56+
'object' => $this->cloneVar($message),
5657
),
5758
);
5859

@@ -63,6 +64,12 @@ public function handle($message, callable $next)
6364
if (is_object($result)) {
6465
$debugRepresentation['result'] = array(
6566
'type' => get_class($result),
67+
'object' => $this->cloneVar($result),
68+
);
69+
} elseif (is_array($result)) {
70+
$debugRepresentation['result'] = array(
71+
'type' => 'array',
72+
'object' => $this->cloneVar($result),
6673
);
6774
} else {
6875
$debugRepresentation['result'] = array(
@@ -77,7 +84,7 @@ public function handle($message, callable $next)
7784
);
7885
}
7986

80-
$this->data[] = $debugRepresentation;
87+
$this->data['messages'][] = $debugRepresentation;
8188

8289
if (null !== $exception) {
8390
throw $exception;
@@ -88,6 +95,6 @@ public function handle($message, callable $next)
8895

8996
public function getMessages(): array
9097
{
91-
return $this->data;
98+
return $this->data['messages'] ?? array();
9299
}
93100
}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/messenger.html.twig

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,28 @@
4141
</thead>
4242
<tbody>
4343
{% for message in collector.messages %}
44-
<tr>
45-
<td>{{ message.message.type }}</td>
46-
<td>
47-
{% if message.result.type is defined %}
48-
{{ message.result.type }}
49-
{% endif %}
50-
51-
{% if message.exception.type is defined %}
52-
{{ message.exception.type }}
53-
{% endif %}
54-
</td>
55-
</tr>
44+
<tr>
45+
<td>
46+
{% if message.result.object is defined %}
47+
{{ profiler_dump(message.message.object, maxDepth=2) }}
48+
{% else %}
49+
{{ message.message.type }}
50+
{% endif %}
51+
</td>
52+
<td>
53+
{% if message.result.object is defined %}
54+
{{ profiler_dump(message.result.object, maxDepth=2) }}
55+
{% elseif message.result.type is defined %}
56+
{{ message.result.type }}
57+
{% if message.result.value is defined %}
58+
{{ message.result.value }}
59+
{% endif %}
60+
{% endif %}
61+
{% if message.exception.type is defined %}
62+
{{ message.exception.type }}
63+
{% endif %}
64+
</td>
65+
</tr>
5666
{% endfor %}
5767
</tbody>
5868
</table>

0 commit comments

Comments
 (0)