<?php
namespace App\EventSubscriber;
use ApiPlatform\Core\EventListener\EventPriorities;
use App\Entity\Abonnement;
use App\Entity\Reservation;
use App\Repository\AbonnementRepository;
use App\Repository\ReservationRepository;
use App\Service\CinetPayService;
use App\Service\ReservationService;
use App\Service\Sender;
use App\Service\Utils;
use JetBrains\PhpStorm\ArrayShape;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ViewEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
class AbonnementSubscriber implements EventSubscriberInterface
{
public function __construct(
private UserPasswordHasherInterface $encoder,
private AbonnementRepository $abonnementRepository,
private Sender $sender,
private CinetPayService $cinetPayService
) {
}
#[
ArrayShape([KernelEvents::VIEW => "array"])
]
public static function getSubscribedEvents(): array
{
return [
KernelEvents::VIEW => [
// ['prePersiste', EventPriorities::PRE_WRITE],
['postPersiste', EventPriorities::POST_WRITE]
],
];
}
public function postPersiste(ViewEvent $event): void
{
$abonnement = $event->getControllerResult();
$method = $event->getRequest()->getMethod();
if (!$abonnement instanceof Abonnement || Request::METHOD_POST !== $method) {
return;
}
}
}