src/Controller/Front/FormationLiveController.php line 38

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