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 b9ed99b

Browse filesBrowse files
committed
[Notifier] [Bridges] Provide EventDispatcher and HttpClient to the transports
1 parent 52839be commit b9ed99b
Copy full SHA for b9ed99b

File tree

Expand file treeCollapse file tree

4 files changed

+26
-14
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+26
-14
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,21 +2594,27 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
25942594

25952595
if (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', MercureTransportFactory::class, $parentPackages, true) && ContainerBuilder::willBeAvailable('symfony/mercure-bundle', MercureBundle::class, $parentPackages, true) && \in_array(MercureBundle::class, $container->getParameter('kernel.bundles'), true)) {
25962596
$container->getDefinition($classToServices[MercureTransportFactory::class])
2597-
->replaceArgument('$registry', new Reference(HubRegistry::class));
2597+
->replaceArgument('$registry', new Reference(HubRegistry::class))
2598+
->replaceArgument('$client', new Reference('http_client'))
2599+
->replaceArgument('$dispatcher', new Reference('event_dispatcher'));
25982600
} elseif (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', MercureTransportFactory::class, $parentPackages, true)) {
25992601
$container->removeDefinition($classToServices[MercureTransportFactory::class]);
26002602
}
26012603

26022604
if (ContainerBuilder::willBeAvailable('symfony/fake-chat-notifier', FakeChatTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'], true)) {
26032605
$container->getDefinition($classToServices[FakeChatTransportFactory::class])
26042606
->replaceArgument('$mailer', new Reference('mailer'))
2605-
->replaceArgument('$logger', new Reference('logger'));
2607+
->replaceArgument('$logger', new Reference('logger'))
2608+
->replaceArgument('$client', new Reference('http_client'))
2609+
->replaceArgument('$dispatcher', new Reference('event_dispatcher'));
26062610
}
26072611

26082612
if (ContainerBuilder::willBeAvailable('symfony/fake-sms-notifier', FakeSmsTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'], true)) {
26092613
$container->getDefinition($classToServices[FakeSmsTransportFactory::class])
26102614
->replaceArgument('$mailer', new Reference('mailer'))
2611-
->replaceArgument('$logger', new Reference('logger'));
2615+
->replaceArgument('$logger', new Reference('logger'))
2616+
->replaceArgument('$client', new Reference('http_client'))
2617+
->replaceArgument('$dispatcher', new Reference('event_dispatcher'));
26122618
}
26132619

26142620
if (isset($config['admin_recipients'])) {

‎src/Symfony/Component/Notifier/Bridge/FakeChat/FakeChatTransportFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/FakeChat/FakeChatTransportFactory.php
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
namespace Symfony\Component\Notifier\Bridge\FakeChat;
1313

1414
use Psr\Log\LoggerInterface;
15+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1516
use Symfony\Component\Mailer\MailerInterface;
1617
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
1718
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
1819
use Symfony\Component\Notifier\Transport\Dsn;
1920
use Symfony\Component\Notifier\Transport\TransportInterface;
21+
use Symfony\Contracts\HttpClient\HttpClientInterface;
2022

2123
/**
2224
* @author Oskar Stark <oskarstark@googlemail.com>
@@ -27,9 +29,9 @@ final class FakeChatTransportFactory extends AbstractTransportFactory
2729
protected $mailer;
2830
protected $logger;
2931

30-
public function __construct(MailerInterface $mailer, LoggerInterface $logger)
32+
public function __construct(MailerInterface $mailer, LoggerInterface $logger, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null)
3133
{
32-
parent::__construct();
34+
parent::__construct($dispatcher, $client);
3335

3436
$this->mailer = $mailer;
3537
$this->logger = $logger;
@@ -47,11 +49,11 @@ public function create(Dsn $dsn): TransportInterface
4749
$to = $dsn->getRequiredOption('to');
4850
$from = $dsn->getRequiredOption('from');
4951

50-
return (new FakeChatEmailTransport($this->mailer, $to, $from))->setHost($mailerTransport);
52+
return (new FakeChatEmailTransport($this->mailer, $to, $from, $this->client, $this->dispatcher))->setHost($mailerTransport);
5153
}
5254

5355
if ('fakechat+logger' === $scheme) {
54-
return new FakeChatLoggerTransport($this->logger);
56+
return new FakeChatLoggerTransport($this->logger, $this->client, $this->dispatcher);
5557
}
5658

5759
throw new UnsupportedSchemeException($dsn, 'fakechat', $this->getSupportedSchemes());

‎src/Symfony/Component/Notifier/Bridge/FakeSms/FakeSmsTransportFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/FakeSms/FakeSmsTransportFactory.php
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
1818
use Symfony\Component\Notifier\Transport\Dsn;
1919
use Symfony\Component\Notifier\Transport\TransportInterface;
20+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
21+
use Symfony\Contracts\HttpClient\HttpClientInterface;
2022

2123
/**
2224
* @author James Hemery <james@yieldstudio.fr>
@@ -28,9 +30,9 @@ final class FakeSmsTransportFactory extends AbstractTransportFactory
2830
protected $mailer;
2931
protected $logger;
3032

31-
public function __construct(MailerInterface $mailer, LoggerInterface $logger)
33+
public function __construct(MailerInterface $mailer, LoggerInterface $logger, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null)
3234
{
33-
parent::__construct();
35+
parent::__construct($dispatcher, $client);
3436

3537
$this->mailer = $mailer;
3638
$this->logger = $logger;
@@ -48,11 +50,11 @@ public function create(Dsn $dsn): TransportInterface
4850
$to = $dsn->getRequiredOption('to');
4951
$from = $dsn->getRequiredOption('from');
5052

51-
return (new FakeSmsEmailTransport($this->mailer, $to, $from))->setHost($mailerTransport);
53+
return (new FakeSmsEmailTransport($this->mailer, $to, $from, $this->client, $this->dispatcher))->setHost($mailerTransport);
5254
}
5355

5456
if ('fakesms+logger' === $scheme) {
55-
return new FakeSmsLoggerTransport($this->logger);
57+
return new FakeSmsLoggerTransport($this->logger, $this->client, $this->dispatcher);
5658
}
5759

5860
throw new UnsupportedSchemeException($dsn, 'fakesms', $this->getSupportedSchemes());

‎src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransportFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransportFactory.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
1919
use Symfony\Component\Notifier\Transport\Dsn;
2020
use Symfony\Component\Notifier\Transport\TransportInterface;
21+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
22+
use Symfony\Contracts\HttpClient\HttpClientInterface;
2123

2224
/**
2325
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
@@ -26,9 +28,9 @@ final class MercureTransportFactory extends AbstractTransportFactory
2628
{
2729
private $registry;
2830

29-
public function __construct(HubRegistry $registry)
31+
public function __construct(HubRegistry $registry, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null)
3032
{
31-
parent::__construct();
33+
parent::__construct($dispatcher, $client);
3234

3335
$this->registry = $registry;
3436
}
@@ -51,7 +53,7 @@ public function create(Dsn $dsn): TransportInterface
5153
throw new IncompleteDsnException(sprintf('Hub "%s" not found. Did you mean one of: "%s"?', $hubId, implode('", "', array_keys($this->registry->all()))));
5254
}
5355

54-
return new MercureTransport($hub, $hubId, $topic);
56+
return new MercureTransport($hub, $hubId, $topic, $this->client, $this->dispatcher);
5557
}
5658

5759
protected function getSupportedSchemes(): array

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.