Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitedb5fed

Browse files
committed
feature#36479 [Notifier][WebProfilerBundle][FrameworkBundle] Add notifier section to profiler (jschaedl)
This PR was squashed before being merged into the 5.2-dev branch.Discussion----------[Notifier][WebProfilerBundle][FrameworkBundle] Add notifier section to profiler| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets | - <!-- prefix each issue number with "Fix #", if any -->| License | MIT| Doc PR | - <!-- required for new features -->This is the first iteration of adding a profiler panel for the new Notifier component:WebProfiler Toolbar:![Screenshot 2020-10-02 at 10 26 35](https://user-images.githubusercontent.com/1880467/94903474-28bece00-049a-11eb-945c-d6ce047b35e8.png)WebProfiler Notifier Panel:![Screenshot 2020-10-02 at 10 28 19](https://user-images.githubusercontent.com/1880467/94903594-5277f500-049a-11eb-8c1e-27e6ec87a51c.png)![Screenshot 2020-10-02 at 10 28 29](https://user-images.githubusercontent.com/1880467/94903591-51df5e80-049a-11eb-935a-9ba130ef69f0.png)![Screenshot 2020-10-02 at 10 28 35](https://user-images.githubusercontent.com/1880467/94903589-5146c800-049a-11eb-8a69-28d362ef6640.png)![Screenshot 2020-10-02 at 10 28 42](https://user-images.githubusercontent.com/1880467/94903586-50159b00-049a-11eb-97bd-382a823087a6.png)An example project can to test the new profiler panel can be found here:https://github.com/jschaedl/notifier-profiler-integrationCommits-------f39e74b [Notifier][WebProfilerBundle][FrameworkBundle] Add notifier section to profiler
2 parentsf8212cc +f39e74b commitedb5fed

File tree

8 files changed

+181
-4
lines changed

8 files changed

+181
-4
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+
{%blocktoolbar %}
4+
{%setevents=collector.events %}
5+
6+
{%ifevents.messages|length %}
7+
{%seticon %}
8+
{%include('@WebProfiler/Icon/mailer.svg') %}
9+
<spanclass="sf-toolbar-value">{{events.messages|length }}</span>
10+
{%endset %}
11+
12+
{%settext %}
13+
<divclass="sf-toolbar-info-piece">
14+
<b>Sent notifications</b>
15+
<spanclass="sf-toolbar-status">{{events.messages|length }}</span>
16+
</div>
17+
18+
{%fortransportinevents.transports %}
19+
<divclass="sf-toolbar-info-piece">
20+
<b>{{transport }}</b>
21+
<spanclass="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+
{%blockhead %}
31+
{{parent() }}
32+
<styletype="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:0033.333333%;
56+
max-width:33.333333%;
57+
}
58+
59+
/* small tabs*/
60+
.sf-tabs-sm.tab-navigationli {
61+
font-size:14px;
62+
padding:.3em.5em;
63+
}
64+
</style>
65+
{%endblock %}
66+
67+
{%blockmenu %}
68+
{%setevents=collector.events %}
69+
70+
<spanclass="label {{events.messages|length?'':'disabled' }}">
71+
<spanclass="icon">{{include('@WebProfiler/Icon/mailer.svg') }}</span>
72+
73+
<strong>Notifications</strong>
74+
{%ifevents.messages|length>0 %}
75+
<spanclass="count">
76+
<span>{{events.messages|length }}</span>
77+
</span>
78+
{%endif %}
79+
</span>
80+
{%endblock %}
81+
82+
{%blockpanel %}
83+
{%setevents=collector.events %}
84+
85+
<h2>Notifications</h2>
86+
87+
{%ifnotevents.messages|length %}
88+
<divclass="empty">
89+
<p>No notifications were sent.</p>
90+
</div>
91+
{%endif %}
92+
93+
<divclass="metrics">
94+
{%fortransportinevents.transports %}
95+
<divclass="metric">
96+
<spanclass="value">{{ events.messages(transport)|length }}</span>
97+
<spanclass="label">{{transport }}</span>
98+
</div>
99+
{%endfor %}
100+
</div>
101+
102+
{%fortransportinevents.transports %}
103+
<h3>{{transport }}</h3>
104+
105+
<divclass="card-block">
106+
<divclass="sf-tabs sf-tabs-sm">
107+
{%foreventin events.events(transport) %}
108+
{%setmessage=event.message %}
109+
<divclass="tab">
110+
<h3class="tab-title">Message #{{loop.index }} <small>({{ event.isQueued()?'queued':'sent' }})</small></h3>
111+
<divclass="tab-content">
112+
<divclass="card">
113+
<divclass="card-block">
114+
<spanclass="label">Subject</span>
115+
<h2class="m-t-10">{{ message.getSubject() ??'(empty)' }}</h2>
116+
</div>
117+
{%ifmessage.getNotificationisdefined %}
118+
<divclass="card-block">
119+
<divclass="row">
120+
<divclass="col">
121+
<spanclass="label">Content</span>
122+
<preclass="prewrap">{{ message.getNotification().getContent() ??'(empty)' }}</pre>
123+
<spanclass="label">Importance</span>
124+
<preclass="prewrap">{{ message.getNotification().getImportance() }}</pre>
125+
</div>
126+
</div>
127+
</div>
128+
{%endif %}
129+
<divclass="card-block">
130+
<divclass="sf-tabs sf-tabs-sm">
131+
{%ifmessage.getNotificationisdefined %}
132+
<divclass="tab">
133+
<h3class="tab-title">Notification</h3>
134+
{%setnotification=event.message.getNotification() %}
135+
<divclass="tab-content">
136+
<preclass="prewrap"style="max-height: 600px">
137+
{{-'Subject:'~ notification.getSubject() }}<br/>
138+
{{-'Content:'~ notification.getContent() }}<br/>
139+
{{-'Importance:'~ notification.getImportance() }}<br/>
140+
{{-'Emoji:'~ (notification.getEmoji()isempty?'(empty)': notification.getEmoji()) }}<br/>
141+
{{-'Exception:'~ notification.getException() ??'(empty)' }}<br/>
142+
{{-'ExceptionAsString:'~ (notification.getExceptionAsString()isempty?'(empty)': notification.getExceptionAsString()) }}
143+
</pre>
144+
</div>
145+
</div>
146+
{%endif %}
147+
<divclass="tab">
148+
<h3class="tab-title">Message Options</h3>
149+
<divclass="tab-content">
150+
<preclass="prewrap"style="max-height: 600px">
151+
{%-if message.getOptions()isnull %}
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 %}

‎src/Symfony/Component/Notifier/Message/ChatMessage.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function getOptions(): ?MessageOptionsInterface
7777
/**
7878
* @return $this
7979
*/
80-
publicfunctiontransport(?string$transport):self
80+
publicfunctiontransport(?string$transport):MessageInterface
8181
{
8282
$this->transport =$transport;
8383

‎src/Symfony/Component/Notifier/Message/EmailMessage.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function getOptions(): ?MessageOptionsInterface
102102
/**
103103
* @return $this
104104
*/
105-
publicfunctiontransport(string$transport):self
105+
publicfunctiontransport(string$transport):MessageInterface
106106
{
107107
if (!$this->messageinstanceof Email) {
108108
thrownewLogicException('Cannot set a Transport on a RawMessage instance.');

‎src/Symfony/Component/Notifier/Message/MessageInterface.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ public function getSubject(): string;
2525
publicfunctiongetOptions(): ?MessageOptionsInterface;
2626

2727
publicfunctiongetTransport(): ?string;
28+
29+
publicfunctiontransport(string$transport):self;
2830
}

‎src/Symfony/Component/Notifier/Message/SmsMessage.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getSubject(): string
8383
/**
8484
* @return $this
8585
*/
86-
publicfunctiontransport(string$transport):self
86+
publicfunctiontransport(string$transport):MessageInterface
8787
{
8888
$this->transport =$transport;
8989

‎src/Symfony/Component/Notifier/Transport/NullTransport.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public function __construct(EventDispatcherInterface $dispatcher = null)
3434

3535
publicfunctionsend(MessageInterface$message):SentMessage
3636
{
37+
if (null ===$message->getTransport()) {
38+
$message->transport((string)$this);
39+
}
40+
3741
if (null !==$this->dispatcher) {
3842
$this->dispatcher->dispatch(newMessageEvent($message));
3943
}

‎src/Symfony/Component/Notifier/Transport/Transports.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ public function supports(MessageInterface $message): bool
5555
publicfunctionsend(MessageInterface$message):SentMessage
5656
{
5757
if (!$transport =$message->getTransport()) {
58-
foreach ($this->transportsas$transport) {
58+
foreach ($this->transportsas$transportName =>$transport) {
5959
if ($transport->supports($message)) {
60+
$message->transport($transportName);
61+
6062
return$transport->send($message);
6163
}
6264
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp