<?php
namespace App\Legacy\EventSubscriber;
use App\Legacy\Events\EmailEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class EmailSubscriber implements EventSubscriberInterface
{
private \Swift_Mailer $mailer;
public function __construct(\Swift_Mailer $mailer)
{
$this->mailer = $mailer;
}
public function emailSend(EmailEvent $event): void
{
$this->mailer->send($event->getMessage());
}
public static function getSubscribedEvents(): array
{
return [
EmailEvent::NAME => 'emailSend',
];
}
}