feature #38068 [Notifier] Register NotificationDataCollector and NotificationLoggerListener service (jschaedl)

This PR was merged into the 5.2-dev branch.

Discussion
----------

[Notifier] Register NotificationDataCollector and NotificationLoggerListener service

| Q             | A
| ------------- | ---
| Branch?       | master<!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #38009  <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | - <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch master.
-->

Commits
-------

1beffd1363 Register NotificationDataCollector and NotificationLoggerListener
This commit is contained in:
Fabien Potencier 2020-09-06 19:14:11 +02:00
commit f15f55ceeb
3 changed files with 31 additions and 1 deletions

View File

@ -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']);

View File

@ -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')
;
};

View File

@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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')])
;
};