123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <?php
- namespace App\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Routing\Requirement\Requirement;
- use Symfony\Component\Routing\Attribute\Route;
- use App\Repository\EventRepository;
- use App\Entity\Event;
- use App\Entity\Gamemaster;
- final class MainController extends AbstractController
- {
- #[Route('/', name: 'app_main')]
- public function index(EventRepository $repository): Response
- {
- // Est-ce qu'un utilisateur est connecté et qu'il est au moins "staff" ?
- $user = $this->getUser();
- $onlyPublicAccess = true;
- if ($user) {
- $roles = $user->getRoles();
- if (in_array('ROLE_STAFF', $roles) || in_array('ROLE_MANAGER', $roles) || in_array('ROLE_ADMIN', $roles)) {
- $onlyPublicAccess = false;
- }
- }
- // Récupérer la liste des événements visibles
- $events = $repository->findEventsToCome($onlyPublicAccess);
- return $this->render('main/index.html.twig', [
- 'events' => $events,
- ]);
- }
- #[Route('/booking', name: 'app_main_booking_main')]
- public function bookingMain(EventRepository $repository): Response
- {
- // Est-ce qu'un utilisateur est connecté et qu'il est au moins "staff" ?
- $user = $this->getUser();
- $onlyPublicAccess = true;
- if ($user) {
- $roles = $user->getRoles();
- if (in_array('ROLE_STAFF', $roles) || in_array('ROLE_MANAGER', $roles) || in_array('ROLE_ADMIN', $roles)) {
- $onlyPublicAccess = false;
- }
- }
- // Récupérer la liste des événements visibles
- $events = $repository->findEventsToCome($onlyPublicAccess);
- if (!$events) {
- $this->addFlash('info', 'Aucun d\'événement n\'est plannifié pour le moment.');
- return $this->redirectToRoute('app_main');
- }
- $event = $events[0];
- return $this->render('main/booking.html.twig', [
- 'event' => $event,
- 'events' => $events
- ]);
- }
- #[Route('/booking/{id}', name: 'app_main_booking', requirements: ['id' => Requirement::UUID_V7], methods: ['GET', 'POST'])]
- public function booking(?Event $event, EventRepository $repository): Response
- {
- // Contrôler qu'un événement est bien ok
- if (!$event) {
- $this->addFlash('danger', 'Événement inconnu !');
- $this->redirectToRoute('app_main_booking_main');
- }
- // Est-ce qu'un utilisateur est connecté et qu'il est au moins "staff" ?
- $user = $this->getUser();
- $onlyPublicAccess = true;
- if ($user) {
- $roles = $user->getRoles();
- if (in_array('ROLE_STAFF', $roles) || in_array('ROLE_MANAGER', $roles) || in_array('ROLE_ADMIN', $roles)) {
- $onlyPublicAccess = false;
- }
- }
- // Récupérer la liste des événements visibles
- $events = $repository->findEventsToCome($onlyPublicAccess);
- return $this->render('main/booking.html.twig', [
- 'event' => $event,
- 'events' => $events
- ]);
- }
- #[Route('/charte-animations', name: 'app_code_of_conduct')]
- public function codeOfConduct(): Response
- {
- // Lire le contenu de la charte des animations depuis un fichier
- $codeContent = file_get_contents(__DIR__ . '/../../public/pages/code.md');
- return $this->render('main/markdown.html.twig', [
- 'codeContent' => $codeContent,
- ]);
- }
- #[Route('/cgu', name: 'app_terms')]
- public function terms(): Response
- {
- // Lire le contenu de la charte des animations depuis un fichier
- $codeContent = file_get_contents(__DIR__ . '/../../public/pages/terms.md');
- return $this->render('main/markdown.html.twig', [
- 'codeContent' => $codeContent,
- ]);
- }
- #[Route('/legal', name: 'app_legal')]
- public function legal(): Response
- {
- // Lire le contenu de la charte des animations depuis un fichier
- $codeContent = file_get_contents(__DIR__ . '/../../public/pages/legal.md');
- return $this->render('main/markdown.html.twig', [
- 'codeContent' => $codeContent,
- ]);
- }
- #[Route('/contact', name: 'app_contact')]
- public function contact(): Response
- {
- // TODO: formulaire de contact avec envoi d'un mail
- // Lire le contenu de la charte des animations depuis un fichier
- $codeContent = file_get_contents(__DIR__ . '/../../public/pages/legal.md');
- return $this->render('main/markdown.html.twig', [
- 'codeContent' => $codeContent,
- ]);
- }
- #[Route('/gamemaster/{id}', name: 'app_gamemaster_public_profile', requirements: ['id' => Requirement::UUID_V7], methods: ['GET'])]
- public function gamemasterPublicProfile(?Gamemaster $gamemaster): Response
- {
- if ($gamemaster) {
- return $this->render('main/_modal.gamemaster.html.twig', [
- 'gamemaster' => $gamemaster,
- ]);
-
- } else {
- $this->addFlash('danger', 'Meneur(euse) de jeu inconnu(e).');
- return $this->redirectToRoute('app_main');
- }
- }
- }
|