Skip to content

Commit

Permalink
wire a clock for the BlueSky transport in the FrameworkBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Jun 17, 2024
1 parent 916718c commit 35f8cf5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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());
}
Expand Down

0 comments on commit 35f8cf5

Please sign in to comment.