From 1beffd13631c76a4dafb69669bbda7547ae20b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4dlich?= Date: Sun, 6 Sep 2020 11:11:54 +0200 Subject: [PATCH] Register NotificationDataCollector and NotificationLoggerListener --- .../FrameworkExtension.php | 7 ++++++- .../Resources/config/notifier.php | 4 ++++ .../Resources/config/notifier_debug.php | 21 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_debug.php diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index c3b22026b3..382b2fe640 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -171,6 +171,7 @@ class FrameworkExtension extends Extension private $messengerConfigEnabled = false; private $mailerConfigEnabled = false; private $httpClientConfigEnabled = false; + private $notifierConfigEnabled = false; /** * Responds to the app.config configuration parameter. @@ -372,7 +373,7 @@ class FrameworkExtension extends Extension $this->registerMailerConfiguration($config['mailer'], $container, $loader); } - if ($this->isConfigEnabled($container, $config['notifier'])) { + if ($this->notifierConfigEnabled = $this->isConfigEnabled($container, $config['notifier'])) { $this->registerNotifierConfiguration($config['notifier'], $container, $loader); } @@ -637,6 +638,10 @@ class FrameworkExtension extends Extension $loader->load('http_client_debug.php'); } + if ($this->notifierConfigEnabled) { + $loader->load('notifier_debug.php'); + } + $container->setParameter('profiler_listener.only_exceptions', $config['only_exceptions']); $container->setParameter('profiler_listener.only_master_requests', $config['only_master_requests']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier.php index 8ec33631c1..99ac562ee7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier.php @@ -19,6 +19,7 @@ use Symfony\Component\Notifier\Channel\EmailChannel; use Symfony\Component\Notifier\Channel\SmsChannel; use Symfony\Component\Notifier\Chatter; use Symfony\Component\Notifier\ChatterInterface; +use Symfony\Component\Notifier\EventListener\NotificationLoggerListener; use Symfony\Component\Notifier\EventListener\SendFailedMessageToNotifierListener; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -101,5 +102,8 @@ return static function (ContainerConfigurator $container) { ->set('texter.messenger.sms_handler', MessageHandler::class) ->args([service('texter.transports')]) ->tag('messenger.message_handler', ['handles' => SmsMessage::class]) + + ->set('notifier.logger_notification_listener', NotificationLoggerListener::class) + ->tag('kernel.event_subscriber') ; }; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_debug.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_debug.php new file mode 100644 index 0000000000..16ae2ccb63 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_debug.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Loader\Configurator; + +use Symfony\Component\Notifier\DataCollector\NotificationDataCollector; + +return static function (ContainerConfigurator $container) { + $container->services() + ->set('notifier.data_collector', NotificationDataCollector::class) + ->args([service('notifier.logger_notification_listener')]) + ; +};