src/Controller/ArticleShowController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Article;
  4. use App\Form\ArticleType;
  5. use App\Repository\ArticleRepository;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  11. use Symfony\Component\HttpFoundation\RedirectResponse;
  12. #[Route('/showactu')]
  13. class ArticleShowController extends AbstractController
  14. {
  15.     public function __construct(private UrlGeneratorInterface $urlGenerator)
  16.     {
  17.     }
  18.     #[Route('/'name'app_article_show_index'methods: ['GET'])]
  19.     public function index(ArticleRepository $articleRepository): Response
  20.     {
  21.         return $this->render('article/indexshow.html.twig', [
  22.             'articles' => $articleRepository->findAll(),
  23.         ]);
  24.     }
  25.     #[Route('/{id}'name'app_article_show'methods: ['GET'])]
  26.     public function show(Article $article): Response
  27.     {
  28.         return $this->render('article/show.html.twig', [
  29.             'article' => $article,
  30.         ]);
  31.     }
  32. }