src/Controller/PageController.php line 43
<?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\Library;use App\Entity\News;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\ArcaPaymentService;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;}public function headerData(){$collections = $this->entityManager->getRepository(Collection::class)->findAll();return $this->render('@web/parts/header_collections.html.twig', ['collections' => $collections]);}public function headerCategory(){$collections = $this->entityManager->getRepository(Category::class)->findAll();return $this->render('@web/parts/header_category.html.twig', ['collections' => $collections]);}#[Route('', name: 'page_index', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]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' => 'en'])]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();$news = $this->entityManager->getRepository(News::class)->findBy(['type' => 1],['id' => 'DESC'], 2);return $this->render('@web/page/heritage.html.twig', ['mainTitle' => $mainTitle,'secondTitle' => $secondTitle,'collections' => $collections,'about' => $about,'news' => $news,'categories' => $categories]);}#[Route('/{_locale}/heritage/news', name: 'page_heritage_news', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function hertiageNews(FixedPagesRepository $pageRepository){$page = $this->entityManager->getRepository(FixedPages::class)->find(6);$news = $this->entityManager->getRepository(News::class)->findBy(['type' => 1],['id' => 'DESC']);return $this->render('@web/page/news.html.twig', ['page' => $page,'news' => $news,]);}#[Route('/{_locale}/liver/news', name: 'page_liver_news', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function liverNews(FixedPagesRepository $pageRepository){$page = $this->entityManager->getRepository(FixedPages::class)->find(1);$news = $this->entityManager->getRepository(News::class)->findBy(['type' => 2],['id' => 'DESC']);return $this->render('@web/page/news.html.twig', ['page' => $page,'news' => $news,]);}#[Route('/{_locale}/heritage/news/{id}', name: 'page_heritage_news_view', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function heritageNewsView(News $news){$page = $news;return $this->render('@web/page/news_view.html.twig', ['news' => $news,'page' => $page,]);}#[Route('/{_locale}/liver/library', name: 'page_liver_library', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function page_liver_library(FixedPagesRepository $pageRepository){$page = $pageRepository->find(6);$library = $this->entityManager->getRepository(Library::class)->findAll();return $this->render('@web/page/library.html.twig', ['page' => $page,'library' => $library]);}#[Route('/{_locale}/liver/news/{id}', name: 'page_liver_news_view', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function liverNewsView(News $news){$page = $news;return $this->render('@web/page/news_view.html.twig', ['news' => $news,'page' => $page,]);}#[Route('/{_locale}/liver/caf', name: 'page_liver_caf', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function liverCafView(){$page = $this->entityManager->getRepository(FixedPages::class)->find(8);return $this->render('@web/page/caf.html.twig', ['page' => $page,]);}#[Route('/{_locale}/liver', name: 'page_liver', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function liver(FixedPagesRepository $pageRepository){$mainTitle = $pageRepository->find(6);$about = $pageRepository->find(7);$products = $this->entityManager->getRepository(Product::class)->findBy(['productType' => 2], ['id' => 'DESC'], 3);$news = $this->entityManager->getRepository(News::class)->findBy(['type' => 2],['id' => 'DESC']);return $this->render('@web/page/liver.html.twig', ['mainTitle' => $mainTitle,'products' => $products,'about' => $about,'news' => $news,]);}#[Route('/{_locale}/liver/products', name: 'page_liver_products', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function liverProducts(Request $request, PageRepository $pageRepository){$page = $this->entityManager->getRepository(FixedPages::class)->find(6);$products = $this->entityManager->getRepository(Product::class)->findBy(['productType' => 2], ['id' => 'DESC']);return $this->render('@web/page/liver-products.html.twig', ['products' => $products,'page' => $page]);}#[Route('/{_locale}/liver/products/{id}', name: 'page_liver_product_view', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function liverProduct(Product $product){$products = $this->entityManager->getRepository(Product::class)->findBy(['productType' => 2], ['id' => 'DESC']);$delivery = $this->entityManager->getRepository(FixedPages::class)->find(4);return $this->render('@web/page/liver-product.html.twig', ['product' => $product,'delivery' => $delivery,'products' => $products]);}#[Route('/{_locale}/heritage/products', name: 'page_heritage_products', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]public function hertiageProducts(Request $request, PageRepository $pageRepository){$collectionId = $request->query->getInt('collection', 0);$categoryId = $request->query->getInt('category', 0);$collection = $this->entityManager->getRepository(Collection::class)->findAll();$category = $this->entityManager->getRepository(Category::class)->findAll();$criteria = [];if ($collectionId > 0) {$criteria['collection'] = $collectionId; // relation id is OK here}if ($categoryId > 0) {$criteria['category'] = $categoryId; // relation id is OK here}$criteria['productType'] = 1;$page = $this->entityManager->getRepository(Collection::class)->find($collectionId);if (!$page) {$page = $this->entityManager->getRepository(FixedPages::class)->find(1);}$products = $this->entityManager->getRepository(Product::class)->findBy($criteria, ['id' => 'DESC']); // optional orderreturn $this->render('@web/page/hertiage-products.html.twig', ['products' => $products,'collection' => $collection,'category' => $category,'collectionId' => $collectionId,'categoryId' => $categoryId,'page' => $page]);}#[Route('/{_locale}/heritage/products/{id}', name: 'page_heritage_product_view', requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'en'])]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' => 'en'])]public function heritageTerms(){$terms = $this->entityManager->getRepository(FixedPages::class)->find(3);return $this->render('@web/page/hertiage-terms.html.twig', ['terms' => $terms]);}#[Route('/pay', name: 'pay')]public function pay(ArcaPaymentService $arca){$orderId = uniqid();$result = $arca->registerOrder(1000, // AMD$orderId,'https://liver.am/payment-success');if (isset($result['formUrl'])) {return $this->redirect($result['formUrl']);}return $this->json($result);}#[Route('/payment-success', name: 'payment_success')]public function success(Request $request, ArcaPaymentService $arca){$orderId = $request->get('orderId');$status = $arca->getOrderStatus($orderId);if ($status['orderStatus'] == 2) {return new Response('Payment successful');}return new Response('Payment failed');}}