src/Legacy/EventSubscriber/EmailSubscriber.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Legacy\EventSubscriber;
  3. use App\Legacy\Events\EmailEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. class EmailSubscriber implements EventSubscriberInterface
  6. {
  7.     private \Swift_Mailer $mailer;
  8.     public function __construct(\Swift_Mailer $mailer)
  9.     {
  10.         $this->mailer $mailer;
  11.     }
  12.     public function emailSend(EmailEvent $event): void
  13.     {
  14.         $this->mailer->send($event->getMessage());
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             EmailEvent::NAME => 'emailSend',
  20.         ];
  21.     }
  22. }