src/Controller/Front/FormationCoachingController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Entity\CoachingSession;
  4. use App\Entity\Elearning;
  5. use App\Entity\Post;
  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. class FormationCoachingController extends AbstractController
  12. {
  13.     /**
  14.      * @Route("/nos-formations-coaching", name="page_nos_formations_coaching")
  15.      * Method ({"GET", "POST"})
  16.      */
  17.     public function index(Request $request, PagesManager $pagesManager): Response
  18.     {
  19.         $em = $this->getDoctrine()->getManager();
  20.         $page = $request->get('page', 1);
  21.         $limit = $request->get('limit', 9);
  22.         $keywords = $request->get('keywords', '');
  23.         $coachingPage = $em->getRepository(Post::class)->findOneBySlug('nos-formations-coaching');
  24.         $formations = $em->getRepository(CoachingSession::class)->search($page, $limit, $keywords);
  25.         $videos = $em->getRepository(Elearning::class)->search(1, 3, null);
  26.         return $this->render('front/formation_coaching/index.html.twig', [
  27.             'blocs' => $pagesManager->getPageBlocs($coachingPage),
  28.             'formations' => $formations,
  29.             'videos' => $videos,
  30.             'page' => ($page+1),
  31.             'limit' => $limit
  32.         ]);
  33.     }
  34.     /**
  35.      * @Route("/nos-formations-coaching-paginate", name="page_nos_formations_coaching_paginate", options={"expose"=true})
  36.      * Method ({"GET", "POST"})
  37.      */
  38.     public function paginate(Request $request): Response
  39.     {
  40.         $em = $this->getDoctrine()->getManager();
  41.         $page = $request->get('page', 1);
  42.         $limit = $request->get('limit', 3);
  43.         $keywords = $request->get('keywords', '');
  44.         $formations = $em->getRepository(CoachingSession::class)->search($page, $limit, $keywords);
  45.         return $this->render('front/formation_coaching/formation_coaching_ajax.html.twig', [
  46.             'formations' => $formations
  47.         ]);
  48.     }
  49.     /**
  50.      * @Route("/formation-coaching/{slug}", name="page_formation_coaching_single")
  51.      * Method ({"GET", "POST"})
  52.      */
  53.     public function show($slug, PagesManager $pagesManager): Response
  54.     {
  55.         $em = $this->getDoctrine()->getManager();
  56.         $formation = $em->getRepository(CoachingSession::class)->findOneBySlug($slug);
  57.         $toSee = $em->getRepository(CoachingSession::class)->getToSee($formation->getCategory(), $slug);
  58.         $coachingPage = $em->getRepository(Post::class)->findOneBySlug('nos-formations-coaching');
  59.         return $this->render('front/formation_coaching/show.html.twig', [
  60.             'formation' => $formation,
  61.             'toSee' => $toSee,
  62.             'blocs' => $pagesManager->getPageBlocs($coachingPage),
  63.         ]);
  64.     }
  65. }