<?php
namespace App\Controller\Front;
use App\Entity\CoachingSession;
use App\Entity\Elearning;
use App\Entity\Post;
use App\Services\PagesManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class FormationCoachingController extends AbstractController
{
/**
* @Route("/nos-formations-coaching", name="page_nos_formations_coaching")
* Method ({"GET", "POST"})
*/
public function index(Request $request, PagesManager $pagesManager): Response
{
$em = $this->getDoctrine()->getManager();
$page = $request->get('page', 1);
$limit = $request->get('limit', 9);
$keywords = $request->get('keywords', '');
$coachingPage = $em->getRepository(Post::class)->findOneBySlug('nos-formations-coaching');
$formations = $em->getRepository(CoachingSession::class)->search($page, $limit, $keywords);
$videos = $em->getRepository(Elearning::class)->search(1, 3, null);
return $this->render('front/formation_coaching/index.html.twig', [
'blocs' => $pagesManager->getPageBlocs($coachingPage),
'formations' => $formations,
'videos' => $videos,
'page' => ($page+1),
'limit' => $limit
]);
}
/**
* @Route("/nos-formations-coaching-paginate", name="page_nos_formations_coaching_paginate", options={"expose"=true})
* Method ({"GET", "POST"})
*/
public function paginate(Request $request): Response
{
$em = $this->getDoctrine()->getManager();
$page = $request->get('page', 1);
$limit = $request->get('limit', 3);
$keywords = $request->get('keywords', '');
$formations = $em->getRepository(CoachingSession::class)->search($page, $limit, $keywords);
return $this->render('front/formation_coaching/formation_coaching_ajax.html.twig', [
'formations' => $formations
]);
}
/**
* @Route("/formation-coaching/{slug}", name="page_formation_coaching_single")
* Method ({"GET", "POST"})
*/
public function show($slug, PagesManager $pagesManager): Response
{
$em = $this->getDoctrine()->getManager();
$formation = $em->getRepository(CoachingSession::class)->findOneBySlug($slug);
$toSee = $em->getRepository(CoachingSession::class)->getToSee($formation->getCategory(), $slug);
$coachingPage = $em->getRepository(Post::class)->findOneBySlug('nos-formations-coaching');
return $this->render('front/formation_coaching/show.html.twig', [
'formation' => $formation,
'toSee' => $toSee,
'blocs' => $pagesManager->getPageBlocs($coachingPage),
]);
}
}