vendor/symfony/notifier/Channel/SmsChannel.php line 25

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Notifier\Channel;
  11. use Symfony\Component\Notifier\Message\SmsMessage;
  12. use Symfony\Component\Notifier\Notification\Notification;
  13. use Symfony\Component\Notifier\Notification\SmsNotificationInterface;
  14. use Symfony\Component\Notifier\Recipient\RecipientInterface;
  15. use Symfony\Component\Notifier\Recipient\SmsRecipientInterface;
  16. /**
  17.  * @author Fabien Potencier <fabien@symfony.com>
  18.  */
  19. class SmsChannel extends AbstractChannel
  20. {
  21.     public function notify(Notification $notificationRecipientInterface $recipientstring $transportName null): void
  22.     {
  23.         $message null;
  24.         if ($notification instanceof SmsNotificationInterface) {
  25.             $message $notification->asSmsMessage($recipient$transportName);
  26.         }
  27.         if (null === $message) {
  28.             $message SmsMessage::fromNotification($notification$recipient);
  29.         }
  30.         if (null !== $transportName) {
  31.             $message->transport($transportName);
  32.         }
  33.         if (null === $this->bus) {
  34.             $this->transport->send($message);
  35.         } else {
  36.             $this->bus->dispatch($message);
  37.         }
  38.     }
  39.     public function supports(Notification $notificationRecipientInterface $recipient): bool
  40.     {
  41.         return $recipient instanceof SmsRecipientInterface;
  42.     }
  43. }