<?php
namespace App\Event;
use App\Service\MailerService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AccountOpeningSubscriber implements EventSubscriberInterface
{
/** @var MailerService */
protected $mailer;
public function __construct(MailerService $mailer)
{
$this->mailer = $mailer;
}
/**
* Send email to Malys and user to inform account opening
*
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public function onLoginAccountOpening(AccountOpeningEvent $event)
{
$this->mailer->sendAccountOpeningEmailToMalys($event->getFormData());
$this->mailer->sendAccountOpeningEmailToUser($event->getFormData());
}
public static function getSubscribedEvents(): array
{
return [
AccountOpeningEvents::LOGIN_ACCOUNT_OPENING => ['onLoginAccountOpening', 0]
];
}
}