<?php
namespace App\Controller\Front;
use App\Entity\Post;
use App\Entity\StageAcademy;
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;
use DateTime;
class StageAcademyController extends AbstractController
{
/**
* @Route("/stage-academie", name="page_stage_academie")
* Method ({"GET", "POST"})
*/
public function index(Request $request, PagesManager $pagesManager): Response
{
$em = $this->getDoctrine()->getManager();
$page = $request->get('page', 1);
$limit = $request->get('limit', 3);
$keywords = $request->get('keywords', '');
$ville = $request->get('ville', '');
$stages = $em->getRepository(StageAcademy::class)->search($page, $limit, $keywords, $ville);
$stagePage = $em->getRepository(Post::class)->findOneBySlug('stage-academie');
return $this->render('front/stage_academy/index.html.twig', [
'blocs' => $pagesManager->getPageBlocs($stagePage),
'stages' => $stages,
'page' => ($page+1),
'limit' => $limit
]);
}
/**
* @Route("/stage-academie-paginate", name="page_stage_academie_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', '');
$ville = $request->get('ville', '');
$stages = $em->getRepository(StageAcademy::class)->search($page, $limit, $keywords, $ville);
return $this->render('front/stage_academy/stage_academy_ajax.html.twig', [
'stages' => $stages
]);
}
/**
* @Route("/stage-academie/{slug}", name="page_stage_academie_details")
* Method ({"GET", "POST"})
*/
public function show($slug, PagesManager $pagesManager): Response
{
$em = $this->getDoctrine()->getManager();
$stageAcademy = $em->getRepository(StageAcademy::class)->findOneBySlug($slug);
$stagePage = $em->getRepository(Post::class)->findOneBySlug('stage-academie');
return $this->render('front/stage_academy/show.html.twig', [
'stage' => $stageAcademy,
'blocs' => $pagesManager->getPageBlocs($stagePage),
]);
}
}