src/EventSubscriber/MeetingBookingSubscriber.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Service\EsMail;
  4. use App\Entity\MeetingBooking;
  5. use App\Event\MeetingBookingPostUpdateEvent;
  6. use App\Event\MeetingBookingPostPersistEvent;
  7. use Symfony\Component\Security\Core\Security;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class MeetingBookingSubscriber implements EventSubscriberInterface
  10. {
  11.     public function __construct(
  12.         private EsMail $esMail,
  13.         private Security $security
  14.     ) {}
  15.     public static function getSubscribedEvents(): array
  16.     {
  17.         return [
  18.             MeetingBookingPostPersistEvent::NAME => 'onCreate',
  19.             MeetingBookingPostUpdateEvent::NAME => 'onUpdate'
  20.         ];
  21.     }
  22.     public function onCreate(MeetingBookingPostPersistEvent $event)
  23.     {
  24.         $object $event->getObject();
  25.         $this->esMail->meetingConfirmationEmail($this->security->getUser(), $object);
  26.     }
  27.     public function onUpdate(MeetingBookingPostUpdateEvent $event)
  28.     {
  29.         $object $event->getObject();
  30.         if ($object->getStatus() === MeetingBooking::STATUS_CANCELED) {
  31.             $this->esMail->meetingCancelationEmail($this->security->getUser(), $object);
  32.         }
  33.     }
  34. }