src/Controller/Front/StageAcademyController.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Entity\Post;
  4. use App\Entity\StageAcademy;
  5. use App\Services\PagesManager;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use DateTime;
  11. class StageAcademyController extends AbstractController
  12. {
  13.     /**
  14.      * @Route("/stage-academie", name="page_stage_academie")
  15.      * Method ({"GET", "POST"})
  16.      */
  17.     public function index(Request $requestPagesManager $pagesManager): Response
  18.     {
  19.         $em $this->getDoctrine()->getManager();
  20.         $page $request->get('page'1);
  21.         $limit $request->get('limit'3);
  22.         $keywords $request->get('keywords''');
  23.         $ville $request->get('ville''');
  24.         $stages $em->getRepository(StageAcademy::class)->search($page$limit$keywords$ville);
  25.         $stagePage $em->getRepository(Post::class)->findOneBySlug('stage-academie');
  26.         return $this->render('front/stage_academy/index.html.twig', [
  27.             'blocs' => $pagesManager->getPageBlocs($stagePage),
  28.             'stages' => $stages,
  29.             'page' => ($page+1),
  30.             'limit' => $limit
  31.         ]);
  32.     }
  33.     /**
  34.      * @Route("/stage-academie-paginate", name="page_stage_academie_paginate", options={"expose"=true})
  35.      * Method ({"GET", "POST"})
  36.      */
  37.     public function paginate(Request $request): Response
  38.     {
  39.         $em $this->getDoctrine()->getManager();
  40.         $page $request->get('page'1);
  41.         $limit $request->get('limit'3);
  42.         $keywords $request->get('keywords''');
  43.         $ville $request->get('ville''');
  44.         $stages $em->getRepository(StageAcademy::class)->search($page$limit$keywords$ville);
  45.         return $this->render('front/stage_academy/stage_academy_ajax.html.twig', [
  46.             'stages' => $stages
  47.         ]);
  48.     }
  49.     /**
  50.      * @Route("/stage-academie/{slug}", name="page_stage_academie_details")
  51.      * Method ({"GET", "POST"})
  52.      */
  53.     public function show($slugPagesManager $pagesManager): Response
  54.     {
  55.         $em $this->getDoctrine()->getManager();
  56.         $stageAcademy $em->getRepository(StageAcademy::class)->findOneBySlug($slug);
  57.         $stagePage $em->getRepository(Post::class)->findOneBySlug('stage-academie');
  58.         return $this->render('front/stage_academy/show.html.twig', [
  59.             'stage' => $stageAcademy,
  60.             'blocs' => $pagesManager->getPageBlocs($stagePage),
  61.         ]);
  62.     }
  63. }