src/Controller/DefaultController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Utilisateur;
  4. use App\Form\ContactType;
  5. use App\Form\ProfilType;
  6. use App\Repository\CmsRepository;
  7. use App\Repository\FaqRepository;
  8. use App\Repository\SlideRepository;
  9. use App\Repository\TabRepository;
  10. use App\Service\EmailService;
  11. use App\Service\UtilisateurService;
  12. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. class DefaultController extends AbstractController
  18. {
  19.     /**
  20.      * @Route("/", name="home")
  21.      * @param SlideRepository $slideRepository
  22.      * @param TabRepository $tabRepository
  23.      * @return Response
  24.      */
  25.     public function index(SlideRepository $slideRepositoryTabRepository $tabRepository)
  26.     {
  27.         $slides $slideRepository->findBy([], ['position' => 'ASC']);
  28.         $tabs $tabRepository->findBy([], ['position' => 'ASC']);
  29.         return $this->render('front/index.html.twig', [
  30.             'slides' => $slides,
  31.             'tabs' => $tabs
  32.         ]);
  33.     }
  34.     /**
  35.      * @Route("/mes-informations", name="mes_informations")
  36.      * @IsGranted(UtilisateurService::ROLE_FILIALE)
  37.      * @param Request $request
  38.      * @return Response
  39.      */
  40.     public function mesInformations(Request $request)
  41.     {
  42.         /** @var Utilisateur $user */
  43.         $user $this->getUser();
  44.         $form $this->createForm(ProfilType::class, $user);
  45.         $form->handleRequest($request);
  46.         if ($form->isSubmitted() && $form->isValid()) {
  47.             $em $this->getDoctrine()->getManager();
  48.             $em->persist($user);
  49.             $em->flush();
  50.             return $this->redirectToRoute('mes_informations');
  51.         }
  52.         return $this->render('default/mes_informations.html.twig', [
  53.             'form' => $form->createView()
  54.         ]);
  55.     }
  56.     /**
  57.      * @Route("/contact", name="contact", methods={"GET","POST"})
  58.      * @IsGranted(UtilisateurService::ROLE_FILIALE)
  59.      * @param Request $request
  60.      * @param EmailService $emailService
  61.      * @return Response
  62.      */
  63.     public function contact(Request $requestEmailService $emailService)
  64.     {
  65.         /** @var Utilisateur $user */
  66.         $user $this->getUser();
  67.         $form =$this->createForm(ContactType::class);
  68.         $form->handleRequest($request);
  69.         if ($form->isSubmitted() && $form->isValid()) {
  70.             $emailService->createContact($user$form->getData());
  71.             $this->addFlash('success''Le message a bien été envoyé.');
  72.         }
  73.         return $this->render('parcours/contact.html.twig', [
  74.             'form' => $form->createView()
  75.         ]);
  76.     }
  77.     /**
  78.      * @Route("/mentions-legales", name="mentions_legales", methods={"GET"})
  79.      * @param Request $request
  80.      * @param CmsRepository $cmsRepository
  81.      * @return Response
  82.      */
  83.     public function mentions_legales(Request $requestCmsRepository $cmsRepository): Response
  84.     {
  85.         $content $cmsRepository->findOneBySlug('mentions-legales');
  86.         return $this->render('front/content.html.twig', [
  87.             'content' => $content
  88.         ]);
  89.     }
  90.     /**
  91.      * @Route("/video", name="video", methods={"GET"})
  92.      * @param Request $request
  93.      * @param CmsRepository $cmsRepository
  94.      * @return Response
  95.      */
  96.     public function video(Request $requestCmsRepository $cmsRepository): Response
  97.     {
  98.         $content $cmsRepository->findOneBySlug('video');
  99.         return $this->render('front/content.html.twig', [
  100.             'content' => $content
  101.         ]);
  102.     }
  103.     /**
  104.      * @Route("/guide", name="guide", methods={"GET"})
  105.      * @param Request $request
  106.      * @param CmsRepository $cmsRepository
  107.      * @return Response
  108.      */
  109.     public function guide(Request $requestCmsRepository $cmsRepository): Response
  110.     {
  111.         $content $cmsRepository->findOneBySlug('guide');
  112.         return $this->render('front/content.html.twig', [
  113.             'content' => $content
  114.         ]);
  115.     }
  116.     /**
  117.      * @Route("/nos-valeurs", name="nosvaleurs", methods={"GET"})
  118.      * @param Request $request
  119.      * @param CmsRepository $cmsRepository
  120.      * @return Response
  121.      */
  122.     public function nosvaleurs(Request $requestCmsRepository $cmsRepository): Response
  123.     {
  124.         $content $cmsRepository->findOneBySlug('nos-valeurs');
  125.         return $this->render('front/content.html.twig', [
  126.             'content' => $content
  127.         ]);
  128.     }
  129.     /**
  130.      * @Route("/faq", name="faq")
  131.      * @param SlideRepository $slideRepository
  132.      * @param TabRepository $tabRepository
  133.      * @return Response
  134.      */
  135.     public function faq(FaqRepository $faqRepository)
  136.     {
  137.         $faqs $faqRepository->findBy([], ['position' => 'ASC']);
  138.         return $this->render('front/faq.html.twig', [
  139.             'faqs' => $faqs
  140.         ]);
  141.     }
  142. }