vendor/symfony/notifier/Channel/PushChannel.php line 24

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\PushMessage;
  12. use Symfony\Component\Notifier\Notification\Notification;
  13. use Symfony\Component\Notifier\Notification\PushNotificationInterface;
  14. use Symfony\Component\Notifier\Recipient\RecipientInterface;
  15. /**
  16.  * @author Tomas Norkūnas <norkunas.tom@gmail.com>
  17.  */
  18. class PushChannel extends AbstractChannel
  19. {
  20.     public function notify(Notification $notificationRecipientInterface $recipientstring $transportName null): void
  21.     {
  22.         $message null;
  23.         if ($notification instanceof PushNotificationInterface) {
  24.             $message $notification->asPushMessage($recipient$transportName);
  25.         }
  26.         if (null === $message) {
  27.             $message PushMessage::fromNotification($notification);
  28.         }
  29.         if (null !== $transportName) {
  30.             $message->transport($transportName);
  31.         }
  32.         if (null === $this->bus) {
  33.             $this->transport->send($message);
  34.         } else {
  35.             $this->bus->dispatch($message);
  36.         }
  37.     }
  38.     public function supports(Notification $notificationRecipientInterface $recipient): bool
  39.     {
  40.         return true;
  41.     }
  42. }