Skip to content

Commit 6f17a82

Browse files
committed
[Notifier] Add mercure bridge
1 parent f61b964 commit 6f17a82

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
2626
use Symfony\Bundle\FrameworkBundle\Routing\RouteLoaderInterface;
2727
use Symfony\Bundle\FullStack;
28+
use Symfony\Bundle\MercureBundle\MercureBundle;
2829
use Symfony\Component\Asset\PackageInterface;
2930
use Symfony\Component\BrowserKit\AbstractBrowser;
3031
use Symfony\Component\Cache\Adapter\AdapterInterface;
@@ -43,6 +44,8 @@
4344
use Symfony\Component\Console\Command\Command;
4445
use Symfony\Component\DependencyInjection\Alias;
4546
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
47+
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
48+
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
4649
use Symfony\Component\DependencyInjection\ChildDefinition;
4750
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
4851
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -112,6 +115,7 @@
112115
use Symfony\Component\Notifier\Bridge\Iqsms\IqsmsTransportFactory;
113116
use Symfony\Component\Notifier\Bridge\LinkedIn\LinkedInTransportFactory;
114117
use Symfony\Component\Notifier\Bridge\Mattermost\MattermostTransportFactory;
118+
use Symfony\Component\Notifier\Bridge\Mercure\MercureTransportFactory;
115119
use Symfony\Component\Notifier\Bridge\Mobyt\MobytTransportFactory;
116120
use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransportFactory;
117121
use Symfony\Component\Notifier\Bridge\Octopush\OctopushTransportFactory;
@@ -2242,6 +2246,7 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
22422246
LinkedInTransportFactory::class => 'notifier.transport_factory.linkedin',
22432247
GatewayApiTransportFactory::class => 'notifier.transport_factory.gatewayapi',
22442248
OctopushTransportFactory::class => 'notifier.transport_factory.octopush',
2249+
MercureTransportFactory::class => 'notifier.transport_factory.mercure',
22452250
];
22462251

22472252
foreach ($classToServices as $class => $service) {
@@ -2250,6 +2255,15 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
22502255
}
22512256
}
22522257

2258+
if (class_exists(MercureTransportFactory::class)) {
2259+
if (!class_exists(MercureBundle::class)) {
2260+
throw new \LogicException('The MercureBundle is not registered in your application. Try running "composer require symfony/mercure-bundle".');
2261+
}
2262+
2263+
$container->getDefinition($classToServices[MercureTransportFactory::class])
2264+
->replaceArgument('$publisherLocator', new ServiceLocatorArgument(new TaggedIteratorArgument('mercure.publisher', null, null, true)));
2265+
}
2266+
22532267
if (isset($config['admin_recipients'])) {
22542268
$notifier = $container->getDefinition('notifier');
22552269
foreach ($config['admin_recipients'] as $i => $recipient) {

Resources/config/notifier_transports.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\Notifier\Bridge\Iqsms\IqsmsTransportFactory;
2323
use Symfony\Component\Notifier\Bridge\LinkedIn\LinkedInTransportFactory;
2424
use Symfony\Component\Notifier\Bridge\Mattermost\MattermostTransportFactory;
25+
use Symfony\Component\Notifier\Bridge\Mercure\MercureTransportFactory;
2526
use Symfony\Component\Notifier\Bridge\Mobyt\MobytTransportFactory;
2627
use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransportFactory;
2728
use Symfony\Component\Notifier\Bridge\Octopush\OctopushTransportFactory;
@@ -135,6 +136,10 @@
135136
->parent('notifier.transport_factory.abstract')
136137
->tag('texter.transport_factory')
137138

139+
->set('notifier.transport_factory.mercure', MercureTransportFactory::class)
140+
->parent('notifier.transport_factory.abstract')
141+
->tag('chatter.transport_factory')
142+
138143
->set('notifier.transport_factory.null', NullTransportFactory::class)
139144
->parent('notifier.transport_factory.abstract')
140145
->tag('chatter.transport_factory')

0 commit comments

Comments
 (0)