<?php
namespace App\Controller\Front;
use App\Repository\CategoryRepository;
use App\Repository\SubCategoryRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class ProductController extends AbstractController
{
/**
* @var CategoryRepository
*/
private CategoryRepository $categoryRepository;
/**
* @var SubCategoryRepository
*/
private SubCategoryRepository $subCategoryRepository;
public function __construct(CategoryRepository $categoryRepository, SubCategoryRepository $subCategoryRepository)
{
$this->categoryRepository = $categoryRepository;
$this->subCategoryRepository = $subCategoryRepository;
}
/**
* @Route("/product-services/{category_slug}/{subcategory_slug}", name="front_product_list")
*/
public function list(string $category_slug, string $subcategory_slug)
{
$category = $this->categoryRepository->findOneBy(['slug' => $category_slug]);
$subCategory = $this->subCategoryRepository->findOneBy(['slug' => $subcategory_slug]);
return $this->render('front/product/product_list.html.twig', [
'currentCategory' => $category,
'currentSubCategory' => $subCategory,
'allCategories' => $this->categoryRepository->findAll(),
'allSubCategories' => $this->subCategoryRepository->findAll(),
]);
}
/**
* @Route("/category/accessories", name="front_product_single")
*/
public function single()
{
return $this->render('front/product/product_single.html.twig');
}
}