<?php
namespace App\Controller;
use App\Entity\Brochures;
use App\Repository\BrochuresRepository;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/ci/brochures")
*/
class BrochuresController extends AbstractController
{
/**
* @Route("/", name="brochures.index")
* @param Request $request
* @param BrochuresRepository $brochuresRepository
* @param PaginatorInterface $paginator
* @return Response
*/
public function index(Request $request, BrochuresRepository $brochuresRepository, PaginatorInterface $paginator): Response
{
$brochures = $paginator->paginate(
$brochuresRepository->findBy(['online' => true], ['id' => 'DESC']), /* query NOT result */
$request->query->getInt('page', 1)/*page number*/,
$request->query->getInt('limit', 12)/*limit per page*/
);
$brochuresAlaUne = $brochuresRepository->features(8);
return $this->render('pages/internes/ci/brochures/index.html.twig', [
'title' => 'Brochures touristiques',
'brochures' => $brochures,
'brochuresAlaUne' => $brochuresAlaUne,
'menu' => "Côte d'Ivoire",
'current_page' => 'ci'
]);
}
/**
* @Route("/{slug}/{id}", name="brochures.show")
* @param $slug
* @param Brochures $brochures
* @return Response
*/
public function show($slug, Brochures $brochures): Response
{
if ($brochures->getSlug() !== $slug) {
return $this->redirectToRoute('brochures.show', [
'id' => $brochures->getId(),
'slug' => $brochures->getSlug(),
], 301);
}
return $this->render('pages/internes/ci/brochures/show.html.twig', [
'title' => $brochures->getName(),
'brochure' => $brochures,
'menu' => "Côte d'Ivoire",
'current_page' => 'ci'
]);
}
}