src/App/Email/Listener/TestEmailListener.php line 16

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Email\Listener;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\Mailer\Event\MessageEvent;
  5. class TestEmailListener implements EventSubscriberInterface
  6. {
  7.     /**
  8.      * @var array<int, MessageEvent>
  9.      */
  10.     private array $beforeSendEvents = [];
  11.     public function beforeSend(MessageEvent $evt): void
  12.     {
  13.         $this->beforeSendEvents[] = $evt;
  14.     }
  15.     /**
  16.      * @return array<int, MessageEvent>
  17.      */
  18.     public function getBeforeSendResults(): array
  19.     {
  20.         return $this->beforeSendEvents;
  21.     }
  22.     /**
  23.      * @return array<string, array<int|string, array<int|string, int|string>|int|string>|string>
  24.      */
  25.     public static function getSubscribedEvents(): array
  26.     {
  27.         return [
  28.             MessageEvent::class => ['beforeSend', -255],
  29.         ];
  30.     }
  31. }