src/Controller/PageController.php line 40

  1. <?php
  2. namespace App\Controller;
  3. use App\Admin\ServicesAdmin;
  4. use App\Entity\Brand;
  5. use App\Entity\Category;
  6. use App\Entity\Collection;
  7. use App\Entity\FixedPages;
  8. use App\Entity\Gallery;
  9. use App\Entity\Page;
  10. use App\Entity\Product;
  11. use App\Entity\Services;
  12. use App\Entity\Testimonials;
  13. use App\Repository\FixedPagesRepository;
  14. use App\Repository\PageRepository;
  15. use App\Services\PageService;
  16. use Doctrine\ORM\EntityManagerInterface;
  17. use Gedmo\Translatable\TranslatableListener;
  18. use Gedmo\Translatable\Entity\Translation;
  19. use Gedmo\Translatable\Entity\Repository\TranslationRepository;
  20. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  21. use Symfony\Component\HttpFoundation\JsonResponse;
  22. use Symfony\Component\HttpFoundation\Request;
  23. use Symfony\Component\HttpFoundation\Response;
  24. use Symfony\Component\Routing\Annotation\Route;
  25. class PageController extends AbstractController
  26. {
  27.     private EntityManagerInterface $entityManager;
  28.     public function __construct(EntityManagerInterface $entityManager)
  29.     {
  30.         $this->entityManager $entityManager;
  31.     }
  32.     #[Route(''name'page_index')]
  33.     public function index(PageRepository  $pageRepository)
  34.     {
  35.         return $this->render('@web/page/index.html.twig',[
  36.         ]);
  37.     }
  38.     #[Route('/{_locale}/heritage'name'page_heritage',requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'hy'])]
  39.     public function hertiage(FixedPagesRepository  $pageRepository)
  40.     {
  41.         $mainTitle $pageRepository->find(1);
  42.         $secondTitle $pageRepository->find(2);
  43.         $about $pageRepository->find(5);
  44.         $collections $this->entityManager->getRepository(Collection::class)->findAll();
  45.         $categories $this->entityManager->getRepository(Category::class)->findAll();
  46.         return $this->render('@web/page/heritage.html.twig',[
  47.             'mainTitle' => $mainTitle,
  48.             'secondTitle' => $secondTitle,
  49.             'collections' => $collections,
  50.             'about' => $about,
  51.             'categories' => $categories
  52.         ]);
  53.     }
  54.     #[Route('/{_locale}/heritage/products'name'page_heritage_products',requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'hy'])]
  55.     public function hertiageProducts(Request $request,PageRepository  $pageRepository)
  56.     {
  57.         $collectionId $request->query->getInt('collection'0);
  58.         $categoryId   $request->query->getInt('category'0);
  59.         $criteria = [];
  60.         if ($collectionId 0) {
  61.             $criteria['collection'] = $collectionId// relation id is OK here
  62.         }
  63.         if ($categoryId 0) {
  64.             $criteria['category'] = $categoryId// relation id is OK here
  65.         }
  66.         $products $this->entityManager
  67.             ->getRepository(Product::class)
  68.             ->findBy($criteria, ['id' => 'DESC']); // optional order
  69.         return $this->render('@web/page/hertiage-products.html.twig',[
  70.             'products' => $products
  71.         ]);
  72.     }
  73.     #[Route('/{_locale}/heritage/products/{id}'name'page_heritage_product_view',requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'hy'])]
  74.     public function hertiageXachProducts(Product $product)
  75.     {
  76.         $products $this->entityManager->getRepository(Product::class)->findAll();
  77.         $delivery $this->entityManager->getRepository(FixedPages::class)->find(4);
  78.         return $this->render('@web/page/hertiage-product.html.twig',[
  79.             'product' => $product,
  80.             'delivery' => $delivery,
  81.             'products' => $products
  82.         ]);
  83.     }
  84.     #[Route('/{_locale}/heritage-terms'name'heritage_terms',requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'hy'])]
  85.     public function heritageTerms()
  86.     {
  87.         $terms $this->entityManager->getRepository(FixedPages::class)->find(3);
  88.         return $this->render('@web/page/hertiage-terms.html.twig',[
  89.             'terms' => $terms
  90.         ]);
  91.     }
  92. }