src/Controller/Front/PagesController.php line 76

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Entity\Elearning;
  4. use App\Entity\Faq;
  5. use App\Entity\LiveSession;
  6. use App\Services\PagesManager;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  12. use App\Entity\Post;
  13. use App\Entity\Slider;
  14. use App\Entity\Temoignage;
  15. /**
  16.  * Class PaymentController
  17.  * @package App\Controller\Front
  18.  * @Route("/")
  19.  */
  20. class PagesController extends AbstractController
  21. {
  22.     private $pagesManager;
  23.     public function __construct(PagesManager $pagesManager)
  24.     {
  25.         $this->pagesManager $pagesManager;
  26.     }
  27.     /**
  28.      * @Route("/", name="homepage")
  29.      * Method ({"GET", "POST"})
  30.      */
  31.     public function homepage(Request $request): Response
  32.     {
  33.         $em $this->getDoctrine()->getManager();
  34.         $page $em->getRepository(Post::class)->findOneBySlug('acceuil');
  35.         $posts $em->getRepository(Post::class)->findBy(['type' => 'post''status' => 'published'], ['createdAt' => 'DESC'], 50);
  36.         $bannerSlides $em->getRepository(Slider::class)->findByShowIn('home');
  37.         $partnerSlides $em->getRepository(Slider::class)->findByShowIn('partner');
  38.         $temoignages $em->getRepository(Temoignage::class)->findAll();
  39.         $videos $em->getRepository(Elearning::class)->search(12null);
  40.         $formations $em->getRepository(LiveSession::class)->search(15nullnull);
  41.         return $this->render('front/pages/homepage.html.twig', [
  42.             'blocs' => $this->pagesManager->getPageBlocs($page),
  43.             'slides' => $bannerSlides,
  44.             'partners' => $partnerSlides,
  45.             'temoignages' => $temoignages,
  46.             'posts' => $posts,
  47.             'videos' => $videos,
  48.             'formations' => $formations
  49.         ]);
  50.     }
  51.     /**
  52.      * @Route("/faq", name="page_foire_aux_questions")
  53.      * Method ({"GET", "POST"})
  54.      */
  55.     public function FoireAuxQuestions(): Response
  56.     {
  57.         $em $this->getDoctrine()->getManager();
  58.         $faqs $em->getRepository(Faq::class)->findBy([], ['ordre' => 'ASC']);
  59.         return $this->render('front/pages/foire_questions.html.twig', [
  60.             'faqs' => $faqs
  61.         ]);
  62.     }
  63.     /**
  64.      * @Route("/faq-footer", name="bloc_faq_footer")
  65.      * Method ({"GET", "POST"})
  66.      */
  67.     public function faqFooter(): Response
  68.     {
  69.         $em $this->getDoctrine()->getManager();
  70.         $faqs $em->getRepository(Faq::class)->findBy(['showInFooter' => true], ['ordre' => 'ASC']);
  71.         return $this->render('front/pages/footer_faq.html.twig', [
  72.             'faqs' => $faqs
  73.         ]);
  74.     }
  75.     /**
  76.      * @Route("/mentions-legales", name="page_mentions_legales")
  77.      * Method ({"GET", "POST"})
  78.      */
  79.     public function mentionsLegales(): Response
  80.     {
  81.         $em $this->getDoctrine()->getManager();
  82.         $page $em->getRepository(Post::class)->findOneBySlug('mentions-legales');
  83.         return $this->render('front/pages/static-pages.html.twig', [
  84.             'page' => $page
  85.         ]);
  86.     }
  87.     /**
  88.      * @Route("/cgv", name="page_cgv")
  89.      * Method ({"GET", "POST"})
  90.      */
  91.     public function cgv(): Response
  92.     {
  93.         $em $this->getDoctrine()->getManager();
  94.         $page $em->getRepository(Post::class)->findOneBySlug('cgv');
  95.         return $this->render('front/pages/static-pages.html.twig', [
  96.             'page' => $page
  97.         ]);
  98.     }
  99.     /**
  100.      * @Route("/prise-en-charge-formation", name="page_prise_en_charge_formation")
  101.      * Method ({"GET", "POST"})
  102.      */
  103.     public function priseEnChargeFormation(): Response
  104.     {
  105.         $em $this->getDoctrine()->getManager();
  106.         $page $em->getRepository(Post::class)->findOneBySlug('prise-en-charge-formation');
  107.         return $this->render('front/pages/static-pages.html.twig', [
  108.             'page' => $page
  109.         ]);
  110.     }
  111.     /**
  112.      * @Route("/donnes-personnelles", name="page_vos_donnes_personnelles")
  113.      * Method ({"GET", "POST"})
  114.      */
  115.     public function personalData(): Response
  116.     {
  117.         $em $this->getDoctrine()->getManager();
  118.         $page $em->getRepository(Post::class)->findOneBySlug('personal-data');
  119.         return $this->render('front/pages/static-pages.html.twig', [
  120.             'page' => $page
  121.         ]);
  122.     }
  123.     /**
  124.      * @Route("/cookies", name="page_politique_cookies")
  125.      * Method ({"GET", "POST"})
  126.      */
  127.     public function cookies(): Response
  128.     {
  129.         $em $this->getDoctrine()->getManager();
  130.         $page $em->getRepository(Post::class)->findOneBySlug('cookies');
  131.         return $this->render('front/pages/static-pages.html.twig', [
  132.             'page' => $page
  133.         ]);
  134.     }
  135.     /**
  136.      * @Route("/presentation-academy", name="page_presentation_academy")
  137.      * Method ({"GET", "POST"})
  138.      */
  139.     public function presentationAcademy(): Response
  140.     {
  141.         $em $this->getDoctrine()->getManager();
  142.         $page $em->getRepository(Post::class)->findOneBySlug('presentation-academy');
  143.         return $this->render('front/pages/presentation_academy.html.twig', [
  144.             'page' => $page,
  145.             'blocs' => $this->pagesManager->getPageBlocs($page)
  146.         ]);
  147.     }
  148.     /**
  149.      * @Route("/presentation", name="page_presentation")
  150.      * Method ({"GET", "POST"})
  151.      */
  152.     public function presentation(): Response
  153.     {
  154.         $em $this->getDoctrine()->getManager();
  155.         $page $em->getRepository(Post::class)->findOneBySlug('presentation');
  156.         return $this->render('front/pages/presentation.html.twig', [
  157.             'page' => $page,
  158.             'blocs' => $this->pagesManager->getPageBlocs($page)
  159.         ]);
  160.     }
  161.     /**
  162.      * @Route("/sitemap.xml", name="sitemap", defaults={"_format"="xml"})
  163.      */
  164.     public function siteMap(Request $request): Response
  165.     {
  166.         // Nous récupérons le nom d'hôte depuis l'URL
  167.         $hostname $request->getSchemeAndHttpHost();
  168.         $urls $this->pagesManager->siteMapGenerator();
  169.         // Fabrication de la réponse XML
  170.         $response = new Response(
  171.             $this->renderView('front/pages/sitemap.html.twig', ['urls' => $urls,
  172.                 'hostname' => $hostname]),
  173.             200
  174.         );
  175.         // Ajout des entêtes
  176.         $response->headers->set('Content-Type''text/xml');
  177.         // On envoie la réponse
  178.         return $response;
  179.     }
  180. }