src/Controller/Front/PostController.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Entity\Post;
  4. use App\Repository\PostRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. /**
  8.  * Class PostController
  9.  * @package App\Controller\Front
  10.  *
  11.  * @Route("/news")
  12.  */
  13. class PostController extends AbstractController
  14. {
  15.     /**
  16.      * @Route("/liste", name="front_post_list")
  17.      */
  18.     public function list(PostRepository $postRepository)
  19.     {
  20.         return $this->render('front/post/list.html.twig', [
  21.             'posts' => $postRepository->findBy([], ['id' => 'DESC'])
  22.         ]);
  23.     }
  24.     /**
  25.      * @Route("/{slug}", name="front_post_single")
  26.      */
  27.     public function single(Post $post)
  28.     {
  29.         return $this->render('front/post/single.html.twig', [
  30.             'post' => $post
  31.         ]);
  32.     }
  33. }