@@ -130,3 +130,48 @@ final readonly class WebhookListener implements ConsumerInterface
130
130
// Handle the mail engagement event
131
131
}
132
132
}
133
+
134
+ Usage in combination with the Notifier component
135
+ ------------------------------------------------
136
+
137
+ The usage of the Webhook component when using a third-party transport in
138
+ the Notifier is very similar to the usage with the Mailer.
139
+
140
+ Currently, the following third-party sms transports support webhooks:
141
+
142
+ ============ ==========================================
143
+ SMS service Parser service name
144
+ ============ ==========================================
145
+ Twilio ``notifier.webhook.request_parser.twilio ``
146
+ ============ ==========================================
147
+
148
+ .. versionadded :: 6.3
149
+
150
+ Webhook support for the Twilio service was introduced in Symfony 6.3.
151
+
152
+ For SMS transports, an additional ``SmsEvent `` is available in the RemoteEvent
153
+ consumer::
154
+
155
+ use Symfony\C omponent\R emoteEvent\A ttribute\A sRemoteEventConsumer;
156
+ use Symfony\C omponent\R emoteEvent\C onsumer\C onsumerInterface;
157
+ use Symfony\C omponent\R emoteEvent\E vent\S ms\S msEvent;
158
+ use Symfony\C omponent\R emoteEvent\R emoteEvent;
159
+
160
+ #[AsRemoteEventConsumer('notifier_twilio')]
161
+ final readonly class WebhookListener implements ConsumerInterface
162
+ {
163
+ public function consume(RemoteEvent $event): void
164
+ {
165
+ if ($event instanceof SmsEvent) {
166
+ $this->handleSmsEvent($event);
167
+ } else {
168
+ // This is not an sms event
169
+ return;
170
+ }
171
+ }
172
+
173
+ private function handleSmsEvent(SmsEvent $event): void
174
+ {
175
+ // Handle the sms event
176
+ }
177
+ }
0 commit comments