Skip to content

Commit 63a63d7

Browse files
committed
[Notifier] Defaults to NoNotifier when sending a notification without recipients
1 parent 0c8fba5 commit 63a63d7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Notifier.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Notifier\Exception\LogicException;
1919
use Symfony\Component\Notifier\Notification\Notification;
2020
use Symfony\Component\Notifier\Recipient\AdminRecipient;
21+
use Symfony\Component\Notifier\Recipient\NoRecipient;
2122
use Symfony\Component\Notifier\Recipient\Recipient;
2223

2324
/**
@@ -42,6 +43,10 @@ public function __construct($channels, ChannelPolicyInterface $policy = null)
4243

4344
public function send(Notification $notification, Recipient ...$recipients): void
4445
{
46+
if (!$recipients) {
47+
$recipients = [new NoRecipient()];
48+
}
49+
4550
foreach ($recipients as $recipient) {
4651
foreach ($this->getChannels($notification, $recipient) as $channel => $transportName) {
4752
$channel->notify($notification, $recipient, $transportName);

0 commit comments

Comments
 (0)