<?php
namespace App\EventListener;
use App\Entity\Applicant;
use App\Entity\Participant;
use App\Event\ParticipantRegisteredEvent;
use App\Event\ParticipantSendPinEvent;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
class EmailMessengerListener
{
private $mailer;
public function __construct(MailerInterface $mailer, private string $toEmail, private string $fromEmail)
{
$this->mailer = $mailer;
}
public function onParticipantRegistered(Applicant $applicant):void
{
dump('EMAIL HIT');
//$participant = $event->getParticipant();
$email = (new TemplatedEmail())
->from(new Address($this->fromEmail, 'NEIP Acceleration Programme'))
->to($applicant->getEmailAddress())
->subject('Thank you for registring')
->htmlTemplate('registration/email.html.twig')
->context([
//'expiration_date' => new \DateTime('+7 days'),
'applicant' => $applicant,
]);
$this->mailer->send($email);
}
}