src/Controller/Front/ProductController.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Repository\CategoryRepository;
  4. use App\Repository\SubCategoryRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. class ProductController extends AbstractController
  8. {
  9.     /**
  10.      * @var CategoryRepository
  11.      */
  12.     private CategoryRepository $categoryRepository;
  13.     /**
  14.      * @var SubCategoryRepository
  15.      */
  16.     private SubCategoryRepository $subCategoryRepository;
  17.     public function __construct(CategoryRepository $categoryRepositorySubCategoryRepository $subCategoryRepository)
  18.     {
  19.         $this->categoryRepository $categoryRepository;
  20.         $this->subCategoryRepository $subCategoryRepository;
  21.     }
  22.     /**
  23.      * @Route("/product-services/{category_slug}/{subcategory_slug}", name="front_product_list")
  24.      */
  25.     public function list(string $category_slugstring $subcategory_slug)
  26.     {
  27.         $category $this->categoryRepository->findOneBy(['slug' => $category_slug]);
  28.         $subCategory $this->subCategoryRepository->findOneBy(['slug' => $subcategory_slug]);
  29.         return $this->render('front/product/product_list.html.twig', [
  30.             'currentCategory' => $category,
  31.             'currentSubCategory' => $subCategory,
  32.             'allCategories' => $this->categoryRepository->findAll(),
  33.             'allSubCategories' => $this->subCategoryRepository->findAll(),
  34.         ]);
  35.     }
  36.     /**
  37.      * @Route("/category/accessories", name="front_product_single")
  38.      */
  39.     public function single()
  40.     {
  41.         return $this->render('front/product/product_single.html.twig');
  42.     }
  43. }