Deprecated: Optional parameter $limit declared before required parameter $excludeIds is implicitly treated as a required parameter in /home/u835281259/domains/globalinternshipservices.com/siteFiles/lib/boab/cms-bundle/src/Repository/ContentRepository.php on line 314

Deprecated: Optional parameter $data declared before required parameter $page is implicitly treated as a required parameter in /home/u835281259/domains/globalinternshipservices.com/siteFiles/lib/boab/cms-bundle/src/Manager/ContentTypeManager.php on line 178
Symfony Profiler

src/EventSubscriber/EmailNotificationSubscriber.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Event\AppointmentEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\Mailer\MailerInterface;
  6. use Symfony\Component\Mime\Email;
  7. use Twig\Environment;
  8. class EmailNotificationSubscriber implements EventSubscriberInterface
  9. {
  10.     public function __construct(private MailerInterface $mailer, private Environment $twig)
  11.     {
  12.         
  13.     }
  14.     public function onBookAppointment(AppointmentEvent $event)
  15.     {
  16.         $appointment $event->getAppointment();
  17.         $htmlContent $this->twig->render('emails/appointment.html.twig',[
  18.             'appointment'=>$appointment
  19.         ]);
  20.         $email = (new Email())
  21.             ->from('mailer@immihive.com')
  22.             ->to('boabramah@gmail.com')
  23.             ->subject('New Appointment Booking')
  24.             ->html($htmlContent);
  25.         $this->mailer->send($email);
  26.     }
  27.     public static function getSubscribedEvents()
  28.     {
  29.         return [
  30.             AppointmentEvent::SUMMITED => 'onBookAppointment',
  31.         ];
  32.     }
  33. }