<?php
namespace App\Controller\Front;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Knp\Component\Pager\PaginatorInterface;
use App\Repository\Law\ConventionRepository;
use App\Entity\Law\Convention;
class ConventionController extends AbstractController
{
public function index(Request $request, ConventionRepository $repository, PaginatorInterface $paginator): Response
{
$keyword = $request->query->get('keyword');
$query = $repository->findConventionsQuery($keyword);
$conventions = $paginator->paginate($query, $request->query->getInt('page', 1), 3);
$recentConventions = $repository->findRecent();
return $this->render('front/convention/index.html.twig', [
'conventions' => $conventions,
'keyword' => $keyword,
'recentConventions' => $recentConventions,
]);
}
public function show(Convention $convention, ConventionRepository $repository): Response
{
$recentConventions = $repository->findRecent();
return $this->render('front/convention/show.html.twig', [
'convention' => $convention,
'recentConventions' => $recentConventions,
]);
}
}