From 35f8cf59acb3f745252384b6c1acbd6fe48094c2 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 17 Jun 2024 23:56:05 +0200 Subject: [PATCH] wire a clock for the BlueSky transport in the FrameworkBundle --- .../DependencyInjection/FrameworkExtension.php | 6 ++++++ .../Notifier/Bridge/Bluesky/BlueskyTransportFactory.php | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index b5d7930ac046c..942358181179a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2865,6 +2865,12 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ ->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE)); } + if (ContainerBuilder::willBeAvailable('symfony/bluesky-notifier', NotifierBridge\Bluesky\BlueskyTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier'])) { + $container->getDefinition($classToServices[NotifierBridge\Bluesky\BlueskyTransportFactory::class]) + ->addArgument(new Reference('logger')) + ->addArgument(new Reference('clock', ContainerBuilder::NULL_ON_INVALID_REFERENCE)); + } + if (isset($config['admin_recipients'])) { $notifier = $container->getDefinition('notifier'); foreach ($config['admin_recipients'] as $i => $recipient) { diff --git a/src/Symfony/Component/Notifier/Bridge/Bluesky/BlueskyTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Bluesky/BlueskyTransportFactory.php index d3c37112a89ef..f69c03555cd52 100644 --- a/src/Symfony/Component/Notifier/Bridge/Bluesky/BlueskyTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Bluesky/BlueskyTransportFactory.php @@ -13,6 +13,7 @@ use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use Symfony\Component\Clock\ClockInterface; use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; use Symfony\Component\Notifier\Transport\AbstractTransportFactory; use Symfony\Component\Notifier\Transport\Dsn; @@ -28,6 +29,7 @@ public function __construct( ?EventDispatcherInterface $dispatcher = null, ?HttpClientInterface $client = null, private ?LoggerInterface $logger = null, + private readonly ?ClockInterface $clock = null, ) { parent::__construct($dispatcher, $client); } @@ -43,7 +45,7 @@ public function create(Dsn $dsn): BlueskyTransport $user = $this->getUser($dsn); $secret = $this->getPassword($dsn); - return (new BlueskyTransport($user, $secret, $this->logger ?? new NullLogger(), $this->client, $this->dispatcher)) + return (new BlueskyTransport($user, $secret, $this->logger ?? new NullLogger(), $this->client, $this->dispatcher, $this->clock)) ->setHost($dsn->getHost()) ->setPort($dsn->getPort()); }