vendor/symfony/notifier/Channel/BrowserChannel.php line 30

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\HttpFoundation\RequestStack;
  12. use Symfony\Component\Notifier\Notification\Notification;
  13. use Symfony\Component\Notifier\Recipient\RecipientInterface;
  14. /**
  15.  * @author Fabien Potencier <fabien@symfony.com>
  16.  */
  17. final class BrowserChannel implements ChannelInterface
  18. {
  19.     private $stack;
  20.     public function __construct(RequestStack $stack)
  21.     {
  22.         $this->stack $stack;
  23.     }
  24.     public function notify(Notification $notificationRecipientInterface $recipientstring $transportName null): void
  25.     {
  26.         if (null === $request $this->stack->getCurrentRequest()) {
  27.             return;
  28.         }
  29.         $message $notification->getSubject();
  30.         if ($notification->getEmoji()) {
  31.             $message $notification->getEmoji().' '.$message;
  32.         }
  33.         $request->getSession()->getFlashBag()->add('notification'$message);
  34.     }
  35.     public function supports(Notification $notificationRecipientInterface $recipient): bool
  36.     {
  37.         return true;
  38.     }
  39. }