src/Controller/CategoriesController.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\CategoriesRepository;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. class CategoriesController extends AbstractController
  8. {
  9.     /**
  10.      * @Route("/categories/{id}", name="categories")
  11.      */
  12.     public function index(CategoriesRepository $cat$id): Response
  13.     {
  14.         $categories $cat->findAll();
  15.         if (!$cat->findBy(['souscat' => $id])) {
  16.             return $this->render('error/404.html.twig', [
  17.                 'menu' => $categories
  18.             ]);
  19.         }
  20.         return $this->render('categories/index.html.twig', [
  21.             'categories' => $cat->findBy(['souscat' => $id]),
  22.             'menu' => $categories,
  23.         ]);
  24.     }
  25. }