Skip to content

Commit ce47c16

Browse files
committed
Register NotificationDataCollector and NotificationLoggerListener
1 parent 5327b3f commit ce47c16

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class FrameworkExtension extends Extension
171171
private $messengerConfigEnabled = false;
172172
private $mailerConfigEnabled = false;
173173
private $httpClientConfigEnabled = false;
174+
private $notifierConfigEnabled = false;
174175

175176
/**
176177
* Responds to the app.config configuration parameter.
@@ -372,7 +373,7 @@ public function load(array $configs, ContainerBuilder $container)
372373
$this->registerMailerConfiguration($config['mailer'], $container, $loader);
373374
}
374375

375-
if ($this->isConfigEnabled($container, $config['notifier'])) {
376+
if ($this->notifierConfigEnabled = $this->isConfigEnabled($container, $config['notifier'])) {
376377
$this->registerNotifierConfiguration($config['notifier'], $container, $loader);
377378
}
378379

@@ -637,6 +638,10 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
637638
$loader->load('http_client_debug.php');
638639
}
639640

641+
if ($this->notifierConfigEnabled) {
642+
$loader->load('notifier_debug.php');
643+
}
644+
640645
$container->setParameter('profiler_listener.only_exceptions', $config['only_exceptions']);
641646
$container->setParameter('profiler_listener.only_master_requests', $config['only_master_requests']);
642647

Resources/config/notifier.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Notifier\Channel\SmsChannel;
2020
use Symfony\Component\Notifier\Chatter;
2121
use Symfony\Component\Notifier\ChatterInterface;
22+
use Symfony\Component\Notifier\EventListener\NotificationLoggerListener;
2223
use Symfony\Component\Notifier\EventListener\SendFailedMessageToNotifierListener;
2324
use Symfony\Component\Notifier\Message\ChatMessage;
2425
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -101,5 +102,8 @@
101102
->set('texter.messenger.sms_handler', MessageHandler::class)
102103
->args([service('texter.transports')])
103104
->tag('messenger.message_handler', ['handles' => SmsMessage::class])
105+
106+
->set('notifier.logger_notification_listener', NotificationLoggerListener::class)
107+
->tag('kernel.event_subscriber')
104108
;
105109
};

Resources/config/notifier_debug.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Component\Notifier\DataCollector\NotificationDataCollector;
15+
16+
return static function (ContainerConfigurator $container) {
17+
$container->services()
18+
->set('notifier.data_collector', NotificationDataCollector::class)
19+
->args([service('notifier.logger_notification_listener')])
20+
;
21+
};

0 commit comments

Comments
 (0)