src/Controller/PageController.php line 50
<?phpnamespace App\Controller;use App\Admin\ServicesAdmin;use App\Entity\Brand;use App\Entity\Category;use App\Entity\Collection;use App\Entity\FixedPages;use App\Entity\Gallery;use App\Entity\Page;use App\Entity\Product;use App\Entity\Services;use App\Entity\Testimonials;use App\Repository\FixedPagesRepository;use App\Repository\PageRepository;use App\Services\PageService;use Doctrine\ORM\EntityManagerInterface;use Gedmo\Translatable\TranslatableListener;use Gedmo\Translatable\Entity\Translation;use Gedmo\Translatable\Entity\Repository\TranslationRepository;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\JsonResponse;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Annotation\Route;class PageController extends AbstractController{private EntityManagerInterface $entityManager;public function __construct(EntityManagerInterface $entityManager){$this->entityManager = $entityManager;}#[Route('', name: 'page_index')]public function index(PageRepository $pageRepository){return $this->render('@web/page/index.html.twig',[]);}#[Route('/{_locale}/heritage', name: 'page_heritage',requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'hy'])]public function hertiage(FixedPagesRepository $pageRepository){$mainTitle = $pageRepository->find(1);$secondTitle = $pageRepository->find(2);$about = $pageRepository->find(5);$collections = $this->entityManager->getRepository(Collection::class)->findAll();$categories = $this->entityManager->getRepository(Category::class)->findAll();return $this->render('@web/page/heritage.html.twig',['mainTitle' => $mainTitle,'secondTitle' => $secondTitle,'collections' => $collections,'about' => $about,'categories' => $categories]);}#[Route('/{_locale}/heritage/products', name: 'page_heritage_products',requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'hy'])]public function hertiageProducts(Request $request,PageRepository $pageRepository){$collectionId = $request->query->getInt('collection', 0);$categoryId = $request->query->getInt('category', 0);$criteria = [];if ($collectionId > 0) {$criteria['collection'] = $collectionId; // relation id is OK here}if ($categoryId > 0) {$criteria['category'] = $categoryId; // relation id is OK here}$products = $this->entityManager->getRepository(Product::class)->findBy($criteria, ['id' => 'DESC']); // optional orderreturn $this->render('@web/page/hertiage-products.html.twig',['products' => $products]);}#[Route('/{_locale}/heritage/products/{id}', name: 'page_heritage_product_view',requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'hy'])]public function hertiageXachProducts(Product $product){$products = $this->entityManager->getRepository(Product::class)->findAll();$delivery = $this->entityManager->getRepository(FixedPages::class)->find(4);return $this->render('@web/page/hertiage-product.html.twig',['product' => $product,'delivery' => $delivery,'products' => $products]);}#[Route('/{_locale}/heritage-terms', name: 'heritage_terms',requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'hy'])]public function heritageTerms(){$terms = $this->entityManager->getRepository(FixedPages::class)->find(3);return $this->render('@web/page/hertiage-terms.html.twig',['terms' => $terms]);}}