<?php
namespace App\EventListener;
use App\Event\BookingEvent;
use App\Service\Booking\EmailService;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
#[AsEventListener(event: BookingEvent::NAME, method: 'onBookingEvent')]
class BookingEventListener
{
private EmailService $emailService;
public function __construct(EmailService $emailService)
{
$this->emailService = $emailService;
}
public function onBookingEvent(BookingEvent $event): void
{
// Récupère les informations nécessaires depuis l'événement
$booking = $event->getBooking();
$oldBooking = $event->getOldBooking();
$eventType = $event->getEventType();
// Appelle le service EmailService pour gérer la notification
$this->emailService->handleBookingNotification($booking, $oldBooking, $eventType);
}
}