src/Controller/EvenementController.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Admin\Article;
  4. use App\Repository\Admin\ArticleRepository;
  5. use App\Repository\Admin\ThemeRepository;
  6. use Knp\Component\Pager\PaginatorInterface;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. /**
  11.  * @Route("/evenements")
  12.  */
  13. class EvenementController extends AbstractController
  14. {
  15.     /**
  16.      * @Route("/", name="evenement_all")
  17.      */
  18.     public function all(Request $requestArticleRepository $articleRepositoryThemeRepository $themeRepositoryPaginatorInterface $paginator){
  19.         if ($request->get('theme_id')){
  20.             $theme_id $request->get('theme_id');
  21.             //$articles = $articleRepository->findByThemeOrderedByDateDesc($themeRepository->find($theme_id));
  22.             $articles $paginator->paginate($articleRepository->findByThemeOrderedByDateDesc($theme_id),
  23.                 $request->query->getInt('page'1),
  24.                 5
  25.             );
  26.         }else{
  27.             $theme_id null;
  28.             //$articles = $articleRepository->findAllByDateDesc();
  29.             $articles $paginator->paginate($articleRepository->findAllByDateDesc(),
  30.                 $request->query->getInt('page'1),
  31.                 5
  32.             );
  33.         }
  34.         $themes $themeRepository->showAll();
  35.         return $this->render('evenement/all.html.twig', [
  36.             'articles'                       => $articles,
  37.             'themes'                         => $themes,
  38.             'theme_id'                       => $theme_id,
  39.         ]);
  40.     }
  41.     /**
  42.      * @Route("/{slug}/{id}", name="evenement_single")
  43.      */
  44.     public function show(Request $requestArticle $articleThemeRepository $themeRepository)
  45.     {
  46.         $themes $themeRepository->showAll();
  47.         $theme_id null;
  48.         return $this->render('evenement/single.html.twig', [
  49.             'article'                       => $article,
  50.             'theme_id'                      => $theme_id,
  51.             'themes'                        => $themes,
  52.         ]);
  53.     }
  54. }