Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 291e776

Browse filesBrowse files
committed
feature #39342 [Notifier] Add mercure bridge (mtarld)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Notifier] Add mercure bridge | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #36481 | License | MIT | Doc PR | symfony/symfony-docs#14840 Add a Notifier bridge for Mercure. In this PR, Mercure is considered as a chatter (I'm still wondering if it's the most appropriate type). The first approach for the DSN is `mercure://jwtToken@host:port/hubPath?topic=/foo/1&secure=false` with: - `topic` optional (defaults to `null`) - `secure` optional (defaults to `true`) I'm not sure about the current way to deal with http/https. Maybe we can just replace the `mercure` scheme by `http|https`? The notification representation is following [Activity Streams](https://www.w3.org/TR/activitystreams-core/#jsonld) #SymfonyHackday Commits ------- 19c6544f42 [Notifier] Add mercure bridge
2 parents 144abcc + 6f17a82 commit 291e776
Copy full SHA for 291e776

File tree

2 files changed

+19
-0
lines changed
Filter options

2 files changed

+19
-0
lines changed

‎DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: DependencyInjection/FrameworkExtension.php
+14Lines 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

Copy file name to clipboardExpand all lines: Resources/config/notifier_transports.php
+5Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.