src/Flexy/FrontBundle/Controller/HomeController.php line 50

Open in your IDE?
  1. <?php
  2. namespace App\Flexy\FrontBundle\Controller;
  3. use App\Flexy\FrontBundle\Entity\PubBanner;
  4. use App\Flexy\FrontBundle\Repository\CategoryProductFrontRepository;
  5. use App\Flexy\FrontBundle\Repository\MasterSliderRepository;
  6. use App\Flexy\FrontBundle\Repository\PubBannerRepository;
  7. use App\Flexy\ShopBundle\Repository\Product\ProductRepository;
  8. use App\Flexy\FrontBundle\Repository\ProductFrontRepository;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Symfony\Component\HttpFoundation\Request;
  13. class HomeController extends AbstractController
  14. {
  15.     #[Route('/dsw'name'multi_access')]
  16.     public function multiAccess
  17.     ProductFrontRepository $productRepository,
  18.     MasterSliderRepository $masterSliderRepository,
  19.     PubBannerRepository $pubBannerRepository,
  20.     CategoryProductFrontRepository $categoryProductFrontRepository): Response
  21.     {
  22.         //return $this->redirectToRoute("index_announce");
  23.         $deals $productRepository->findDeals();
  24.         if($this->getUser() != null && $this->getUser()->getRoles()[0] == "ROLE_CUSTOMER"){
  25.             return $this->render('@Flexy\FrontBundle/templates/home/index.html.twig', [
  26.                 'products' => $productRepository->findAll(),
  27.                 'masterSliders'=> $masterSliderRepository->findBy(["isEnabled"=>true]),
  28.                 'pubBanners'=> $pubBannerRepository->findBy(["isEnabled"=>true]),
  29.                 'deals'=>$deals,
  30.                 'categoriesProduct'=> $categoryProductFrontRepository->findBy(["parentCategory"=>null])
  31.             ]);
  32.         }else{
  33.         return $this->render('@Flexy\FrontBundle/templates/home/multiAccess.html.twig');
  34.     }
  35.     }
  36.     #[Route('/marketplace'name'front_home')]
  37.     public function index(
  38.         ProductFrontRepository $productRepository,
  39.         MasterSliderRepository $masterSliderRepository,
  40.         PubBannerRepository $pubBannerRepository,
  41.         CategoryProductFrontRepository $categoryProductFrontRepository
  42.         
  43.         ): Response
  44.     {
  45.         $deals $productRepository->findDeals();
  46.         
  47.         return $this->render('@Flexy\FrontBundle/templates/home/index.html.twig', [
  48.             'products' => $productRepository->findAll(),
  49.             'masterSliders'=> $masterSliderRepository->findBy(["isEnabled"=>true]),
  50.             'pubBanners'=> $pubBannerRepository->findBy(["isEnabled"=>true]),
  51.             'deals'=>$deals,
  52.             'categoriesProduct'=> $categoryProductFrontRepository->findBy(["parentCategory"=>null])
  53.         ]);
  54.     }
  55.     #[Route('/contact'name'contact')]
  56.     public function contact(Request $request,ProductRepository $productRepository,\Swift_Mailer $mailer,): Response
  57.     {
  58.        
  59.          
  60.         if ($request->isMethod('POST')) {
  61.             
  62.             $name=$request->request->get("customerName");
  63.             $email=$request->request->get("customerEmail");
  64.             $subject=$request->request->get("contactSujet");
  65.             $contenu=$request->request->get("contactMessage");
  66.              
  67.              $message = (new \Swift_Message("Page contact O'mall"))
  68.              ->setFrom(['contact@omall.ma'=>"O'Mall"])
  69.              ->setTo(['contact.info@o-mall.ma'=>"Page contact O'mall"])
  70.              ->setBody(
  71.              $this->renderView(
  72.                 '@Flexy/FrontBundle/templates/registration/mail_frommarketplace.html.twig',
  73.                 [   
  74.                     "client"=>$name,
  75.                     "Email"=>$email,
  76.                     "subject"=>$subject,
  77.                     "message"=>$contenu
  78.                     ]
  79.                
  80.              ),
  81.                  'text/html'
  82.              );
  83.            
  84.              $mailer->send($message);  
  85.              if ($mailer->send($message))
  86.                 {
  87.                     $this->addFlash("success","Votre Email a été envoyer le service client omall va traité votre demande "); 
  88.                 }
  89.                  
  90.             
  91.         }
  92.         
  93.         
  94.         return $this->render('@Flexy\FrontBundle/templates/home/contact.html.twig', [
  95.             'products' => $productRepository->findAll(),
  96.         ]);
  97.     }
  98.     #[Route('/refund'name'refund_order')]
  99.     public function refund(ProductRepository $productRepository): Response
  100.     {
  101.         return $this->render('@Flexy\FrontBundle/templates/home/refundOrder.html.twig');
  102.     } 
  103.     
  104.     #[Route('/banner-block/{id}'name'pubBannerBlock')]
  105.     public function pubBannerBlock(PubBanner $pubBanner): Response
  106.     {
  107.         return $this->render('@Flexy\FrontBundle/templates/include-pubs/_singlePubBanner.html.twig', [
  108.             'singleBanner' => $pubBanner,
  109.         ]);
  110.     }
  111. }