conflict resolved
This commit is contained in:
@@ -54,7 +54,7 @@ class SortieController extends AbstractController
|
||||
}
|
||||
|
||||
// Définir les relations et l'état initial
|
||||
$etat = $etatRepository->findOneBy(['libelle' => 'Créée']);
|
||||
$etat = $etatRepository->findOneBy(['libelle' => 'Ouverte']);
|
||||
if (!$etat) {
|
||||
$this->addFlash('error', 'Erreur interne : état introuvable.');
|
||||
return $this->redirectToRoute('sortie_create');
|
||||
@@ -100,10 +100,12 @@ class SortieController extends AbstractController
|
||||
public function inscription(
|
||||
string $id,
|
||||
EntityManagerInterface $entityManager,
|
||||
TokenStorageInterface $tokenStorage
|
||||
TokenStorageInterface $tokenStorage,
|
||||
ParticipantRepository $participantRepository,
|
||||
): Response {
|
||||
$userConnect = $tokenStorage->getToken()?->getUser();
|
||||
if (!$userConnect) {
|
||||
$participant = $participantRepository->find($userConnect->getIdParticipant());
|
||||
if (!$participant) {
|
||||
$this->addFlash('error', 'Vous devez être connecté pour vous inscrire.');
|
||||
return $this->redirectToRoute('app_login');
|
||||
}
|
||||
@@ -117,14 +119,14 @@ class SortieController extends AbstractController
|
||||
// Conditions supplémentaires pour l'inscription
|
||||
if ($sortie->getEtat()->getLibelle() !== 'Ouverte') {
|
||||
$this->addFlash('error', 'Cette sortie n\'est pas ouverte aux inscriptions.');
|
||||
} elseif ($sortie->getParticipants()->contains($userConnect)) {
|
||||
} elseif ($sortie->getParticipants()->contains($participant)) {
|
||||
$this->addFlash('error', 'Vous êtes déjà inscrit à cette sortie.');
|
||||
} elseif ($sortie->getParticipants()->count() >= $sortie->getNbInscriptionsMax()) {
|
||||
$this->addFlash('error', 'Cette sortie est complète.');
|
||||
} elseif ($sortie->getDateLimiteInscription() < new DateTime()) {
|
||||
$this->addFlash('error', "La date limite d'inscription est dépassée");
|
||||
} else {
|
||||
$sortie->addParticipant($userConnect);
|
||||
$sortie->addParticipant($participant);
|
||||
$entityManager->persist($sortie);
|
||||
$entityManager->flush();
|
||||
$this->addFlash('success', 'Votre inscription a été validée.');
|
||||
|
||||
Reference in New Issue
Block a user