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

Skip to content

Commit 77a07d9

Browse files
committed
Add notifier section to profiler
1 parent 3b1ab7b commit 77a07d9

File tree

2 files changed

+169
-0
lines changed

2 files changed

+169
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_debug.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
$container->services()
1818
->set('notifier.data_collector', NotificationDataCollector::class)
1919
->args([service('notifier.logger_notification_listener')])
20+
->tag('data_collector', ['template' => '@WebProfiler/Collector/notifier.html.twig', 'id' => 'notifier'])
2021
;
2122
};
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
2+
3+
{% block toolbar %}
4+
{% set events = collector.events %}
5+
6+
{% if events.messages|length %}
7+
{% set icon %}
8+
{% include('@WebProfiler/Icon/mailer.svg') %}
9+
<span class="sf-toolbar-value">{{ events.messages|length }}</span>
10+
{% endset %}
11+
12+
{% set text %}
13+
<div class="sf-toolbar-info-piece">
14+
<b>Sent notifications</b>
15+
<span class="sf-toolbar-status">{{ events.messages|length }}</span>
16+
</div>
17+
18+
{% for transport in events.transports %}
19+
<div class="sf-toolbar-info-piece">
20+
<b>{{ transport }}</b>
21+
<span class="sf-toolbar-status">{{ events.messages(transport)|length }}</span>
22+
</div>
23+
{% endfor %}
24+
{% endset %}
25+
26+
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { 'link': profiler_url }) }}
27+
{% endif %}
28+
{% endblock %}
29+
30+
{% block head %}
31+
{{ parent() }}
32+
<style type="text/css">
33+
/* utility classes */
34+
.m-t-0 { margin-top: 0 !important; }
35+
.m-t-10 { margin-top: 10px !important; }
36+
37+
/* basic grid */
38+
.row {
39+
display: flex;
40+
flex-wrap: wrap;
41+
margin-right: -15px;
42+
margin-left: -15px;
43+
}
44+
.col {
45+
flex-basis: 0;
46+
flex-grow: 1;
47+
max-width: 100%;
48+
position: relative;
49+
width: 100%;
50+
min-height: 1px;
51+
padding-right: 15px;
52+
padding-left: 15px;
53+
}
54+
.col-4 {
55+
flex: 0 0 33.333333%;
56+
max-width: 33.333333%;
57+
}
58+
59+
/* small tabs */
60+
.sf-tabs-sm .tab-navigation li {
61+
font-size: 14px;
62+
padding: .3em .5em;
63+
}
64+
</style>
65+
{% endblock %}
66+
67+
{% block menu %}
68+
{% set events = collector.events %}
69+
70+
<span class="label {{ events.messages|length ? '' : 'disabled' }}">
71+
<span class="icon">{{ include('@WebProfiler/Icon/mailer.svg') }}</span>
72+
73+
<strong>Notifications</strong>
74+
{% if events.messages|length > 0 %}
75+
<span class="count">
76+
<span>{{ events.messages|length }}</span>
77+
</span>
78+
{% endif %}
79+
</span>
80+
{% endblock %}
81+
82+
{% block panel %}
83+
{% set events = collector.events %}
84+
85+
<h2>Notifications</h2>
86+
87+
{% if not events.messages|length %}
88+
<div class="empty">
89+
<p>No notifications were sent.</p>
90+
</div>
91+
{% endif %}
92+
93+
<div class="metrics">
94+
{% for transport in events.transports %}
95+
<div class="metric">
96+
<span class="value">{{ events.messages(transport)|length }}</span>
97+
<span class="label">{{ transport }}</span>
98+
</div>
99+
{% endfor %}
100+
</div>
101+
102+
{% for transport in events.transports %}
103+
<h3>{{ transport }}</h3>
104+
105+
<div class="card-block">
106+
<div class="sf-tabs sf-tabs-sm">
107+
{% for event in events.events(transport) %}
108+
{% set message = event.message %}
109+
<div class="tab">
110+
<h3 class="tab-title">Message #{{ loop.index }} <small>({{ event.isQueued() ? 'queued' : 'sent' }})</small></h3>
111+
<div class="tab-content">
112+
<div class="card">
113+
<div class="card-block">
114+
<span class="label">Subject</span>
115+
<h2 class="m-t-10">{{ message.getSubject() ?? '(empty)' }}</h2>
116+
</div>
117+
{% if message.getNotification is defined %}
118+
<div class="card-block">
119+
<div class="row">
120+
<div class="col">
121+
<span class="label">Content</span>
122+
<pre class="prewrap">{{ message.getNotification().getContent() ?? '(empty)' }}</pre>
123+
<span class="label">Importance</span>
124+
<pre class="prewrap">{{ message.getNotification().getImportance() }}</pre>
125+
</div>
126+
</div>
127+
</div>
128+
{% endif %}
129+
<div class="card-block">
130+
<div class="sf-tabs sf-tabs-sm">
131+
{% if message.getNotification is defined %}
132+
<div class="tab">
133+
<h3 class="tab-title">Notification</h3>
134+
{% set notification = event.message.getNotification() %}
135+
<div class="tab-content">
136+
<pre class="prewrap" style="max-height: 600px">
137+
{{- 'Subject: ' ~ notification.getSubject() }}<br/>
138+
{{- 'Content: ' ~ notification.getContent() }}<br/>
139+
{{- 'Importance: ' ~ notification.getImportance() }}<br/>
140+
{{- 'Emoji: ' ~ (notification.getEmoji() is empty ? '(empty)' : notification.getEmoji()) }}<br/>
141+
{{- 'Exception: ' ~ notification.getException() ?? '(empty)' }}<br/>
142+
{{- 'ExceptionAsString: ' ~ (notification.getExceptionAsString() is empty ? '(empty)' : notification.getExceptionAsString()) }}
143+
</pre>
144+
</div>
145+
</div>
146+
{% endif %}
147+
<div class="tab">
148+
<h3 class="tab-title">Message Options</h3>
149+
<div class="tab-content">
150+
<pre class="prewrap" style="max-height: 600px">
151+
{%- if message.getOptions() is null %}
152+
{{- '(empty)' }}
153+
{%- else %}
154+
{{- message.getOptions()|json_encode(constant('JSON_PRETTY_PRINT')) }}
155+
{%- endif %}
156+
</pre>
157+
</div>
158+
</div>
159+
</div>
160+
</div>
161+
</div>
162+
</div>
163+
</div>
164+
{% endfor %}
165+
</div>
166+
</div>
167+
{% endfor %}
168+
{% endblock %}

0 commit comments

Comments
 (0)