src/Controller/PageController.php line 47

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\ApplicationRepository;
  4. use App\Repository\BibliothequePedagogiqueRepository;
  5. use App\Repository\CorpusRepository;
  6. use App\Repository\ImageRepository;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\RequestStack;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  13. class PageController extends AbstractController
  14. {
  15.     private $twig_parameter = [];
  16.     private $corpusRepository;
  17.     private $imageRepository;
  18.     private $bibliothequePedagogiqueRepository;
  19.     private $appRepository;
  20.     public function __construct(RequestStack $requestStackCorpusRepository $corpusRepositoryImageRepository $imageRepositoryBibliothequePedagogiqueRepository $bibliothequePedagogiqueRepositoryApplicationRepository $appRepository)
  21.     {
  22.         $this->corpusRepository $corpusRepository;
  23.         $this->imageRepository $imageRepository;
  24.         $this->bibliothequePedagogiqueRepository $bibliothequePedagogiqueRepository;
  25.         $this->appRepository $appRepository;
  26.         $this->twig_parameter['corpusCount'] = count($this->corpusRepository->findBy(['active' => true]));
  27.         $this->twig_parameter['locale'] = $requestStack->getCurrentRequest()->getLocale() == "fr" "Fr" "En";
  28.     }
  29.     /**
  30.      * @Route("/", name="{redirectionLocal}")
  31.      */
  32.     public function redirectionLocal(Request $request): Response
  33.     {
  34.         return $this->redirectToRoute('home', ['_locale' => $request->getLocale()]);
  35.     }
  36.     /**
  37.      * @Route("/{_locale}", name="home")
  38.      */
  39.     public function home(): Response
  40.     {
  41.         $applications $this->appRepository->getSlug();
  42.         $this->twig_parameter['applications'] = $applications;
  43.         return $this->render('bdnf/accueil.html.twig',$this->twig_parameter);
  44.     }
  45.     /**
  46.      * @Route("/{_locale}/bibliotheque-pedagogique", name="bibliotheque-pedagogique")
  47.      */
  48.     public function bibliotheque_pedagogique(): Response
  49.     {
  50.         $fiches $this->bibliothequePedagogiqueRepository->findBy(['active' => true]);
  51.         $categoryFiches = [];
  52.         $defaultFiches = [];
  53.         foreach($fiches as $fiche){
  54.             if($fiche->getCategory() != null){
  55.                 if(empty($categoryFiches[$fiche->getCategory()])){
  56.                     $categoryFiches[$fiche->getCategory()] = [$fiche];
  57.                 } else {
  58.                     $categoryFiches[$fiche->getCategory()][] = $fiche;
  59.                 }
  60.             } else {
  61.                 $defaultFiches[] = $fiche;
  62.             }
  63.         }
  64.         $this->twig_parameter['defaultFiches'] = $defaultFiches;
  65.         $this->twig_parameter['categoryFiches'] = $categoryFiches;
  66.         return $this->render('bdnf/bibliotheque-pedagogique.html.twig',$this->twig_parameter);
  67.     }
  68.     /**
  69.      * @Route("/{_locale}/cookies", name="cookies")
  70.      */
  71.     public function cookies(): Response
  72.     {
  73.         return $this->render('bdnf/cookies.html.twig',$this->twig_parameter);
  74.     }
  75.     /**
  76.      * @Route("/{_locale}/cgu", name="cgu")
  77.      */
  78.     public function cgu(): Response
  79.     {
  80.         return $this->render('bdnf/cgu.html.twig',$this->twig_parameter);
  81.     }
  82.     /**
  83.      * @Route("/{_locale}/corpus", name="corpus")
  84.      */
  85.     public function corpus(): Response
  86.     {
  87.         $corpus $this->corpusRepository->findBy(["active" => true],['position'=>'DESC']);
  88.         $this->twig_parameter['corpus'] = $corpus;
  89.         return $this->render('bdnf/corpus.html.twig',$this->twig_parameter);
  90.     }
  91.     /**
  92.      * @Route("/{_locale}/galerie", name="galerie")
  93.      */
  94.     public function galerie(): Response
  95.     {
  96.         return $this->render('bdnf/galerie.html.twig',$this->twig_parameter);
  97.     }
  98.     /**
  99.      * @Route("/{_locale}/galerie/comic_strip", name="galerie_comic_strip")
  100.      */
  101.     public function galerie_comic_strip(): Response
  102.     {
  103.         return $this->render('bdnf/galerie_comic_strip.html.twig',$this->twig_parameter);
  104.     }
  105.     /**
  106.      * @Route("/{_locale}/galerie/bd_patrimoniale", name="galerie_bd_patrimoniale")
  107.      */
  108.     public function galerie_bd_patrimoniale(): Response
  109.     {
  110.         return $this->render('bdnf/galerie_bd_patrimoniale.html.twig',$this->twig_parameter);
  111.     }
  112.     /**
  113.      * @Route("/{_locale}/galerie/webtoon", name="galerie_webtoon")
  114.      */
  115.     public function galerie_webtoon(): Response
  116.     {
  117.         return $this->render('bdnf/galerie_webtoon.html.twig',$this->twig_parameter);
  118.     }
  119.     /**
  120.      * @Route("/{_locale}/galerie/franco_belge", name="galerie_franco_belge")
  121.      */
  122.     public function galerie_franco_belge(): Response
  123.     {
  124.         return $this->render('bdnf/galerie_franco_belge.html.twig',$this->twig_parameter);
  125.     }
  126.     /**
  127.      * @Route("/{_locale}/faq", name="faq")
  128.      */
  129.     public function faq(): Response
  130.     {
  131.         return $this->render('bdnf/faq.html.twig',$this->twig_parameter);
  132.     }
  133.     /**
  134.      * @Route("/{_locale}/contact", name="contact")
  135.      */
  136.     public function contact(): Response
  137.     {
  138.         return $this->render('bdnf/contact.html.twig',$this->twig_parameter);
  139.     }
  140.     /**
  141.      * @Route("/{_locale}/concours", name="concours")
  142.      */
  143.     public function concours($_locale): Response
  144.     {
  145.         if($_locale == 'en'){
  146.             return $this->render('bdnf/concours_no_content.html.twig',$this->twig_parameter);
  147.         } else {
  148.             return $this->render('bdnf/concours.html.twig',$this->twig_parameter);
  149.         }
  150.     }
  151.     /**
  152.      * @Route("/{_locale}/credits", name="credits")
  153.      */
  154.     public function credits(): Response
  155.     {
  156.         return $this->render('bdnf/credits.html.twig',$this->twig_parameter);
  157.     }
  158.     /**
  159.      * @Route("/{_locale}/mentions-legales", name="mentions-legales")
  160.      */
  161.     public function mentions_legales(): Response
  162.     {
  163.         return $this->render('bdnf/mentions_legales.html.twig',$this->twig_parameter);
  164.     }
  165.     /**
  166.      * @Route("/{_locale}/presse", name="presse")
  167.      */
  168.     public function presse(): Response
  169.     {
  170.         return $this->render('bdnf/presse.html.twig',$this->twig_parameter);
  171.     }
  172.     /**
  173.      * @Route("/{_locale}/historique_des_versions", name="historique_des_versions")
  174.      */
  175.     public function historique_des_versions(): Response
  176.     {
  177.         return $this->render('bdnf/historique_version.html.twig',$this->twig_parameter);
  178.     }
  179. }