src/Controller/Front/PublicationController.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Knp\Component\Pager\PaginatorInterface;
  7. use App\Repository\Publication\PublicationRepository;
  8. use App\Entity\Publication\Publication;
  9. class PublicationController extends AbstractController
  10. {
  11.     public function index(Request $requestPublicationRepository $repositoryPaginatorInterface $paginator): Response
  12.     {
  13.         $keyword $request->query->get('keyword');
  14.         $query $repository->findPublicationsQuery($keyword);
  15.         $publications $paginator->paginate($query$request->query->getInt('page'1), 3);
  16.         $recentPublications $repository->findRecent();
  17.         return $this->render('front/publication/index.html.twig', [
  18.             'publications' => $publications,
  19.             'keyword' => $keyword,
  20.             'recentPublications' => $recentPublications,
  21.         ]);
  22.     }
  23.     public function show(Publication $publicationPublicationRepository $repository): Response
  24.     {
  25.         $recentPublications $repository->findRecent();
  26.         return $this->render('front/publication/show.html.twig', [
  27.             'publication' => $publication,
  28.             'recentPublications' => $recentPublications,
  29.         ]);
  30.     }
  31. }