src/Controller/Shop/HomeController.php line 159

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Shop;
  3. use App\Component\Order\OrderFactory;
  4. use App\Component\Product\Model\Product;
  5. use App\Component\Product\Repository\ProductRepository;
  6. use App\Entity\Images;
  7. use App\Form\ClearCartType;
  8. use App\Form\SetDiscountType;
  9. use App\Form\SetPaymentType;
  10. use App\Form\SetShipmentType;
  11. use App\Repository\AnnoncesRepository;
  12. use App\Repository\ImagesRepository;
  13. use App\Repository\WishListRepository;
  14. use App\Service\CurrencyService;
  15. use App\Service\TopUpService;
  16. use Symfony\Component\Translation\TranslatorInterface;
  17. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  18. use Symfony\Component\HttpFoundation\JsonResponse;
  19. use Symfony\Component\HttpFoundation\Request;
  20. use Symfony\Component\HttpFoundation\Response;
  21. use Symfony\Component\HttpFoundation\Session\Session;
  22. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  23. use Symfony\Component\Routing\Annotation\Route;
  24. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  25. class HomeController extends AbstractController
  26. {
  27.     /**
  28.      * @var TranslatorInterface
  29.      */
  30.     private $translator;
  31.    
  32.     public function __construct(TranslatorInterface $translator)
  33.     {
  34.         $this->translator $translator;       
  35.     }
  36.     /**
  37.      * @Route({
  38.      *     "fr": "/",
  39.      *     "en": "/en"
  40.      * }, name="home1")
  41.      *  @param Request $request
  42.      *  @param CurrencyService $currency
  43.      *
  44.      */
  45.      
  46.     public function index(Request $requestProductRepository $productRepositoryOrderFactory $orderCurrencyService $currencySessionInterface $sessionWishListRepository $wishrepoAuthenticationUtils $authenticationUtils): Response
  47.     {
  48.         $products $productRepository->findProductByCat(1);
  49.         $products_2 $productRepository->findProductByCat(2);
  50.         $products_3 $productRepository->findProductByCat(3);
  51.         $products_4 $productRepository->findProductByDate();
  52.         $products_5 $productRepository->findProductByCat(5);
  53.         $products_6 $productRepository->findProductByCat(6);
  54.         $products_7 $productRepository->findAllAction();
  55.         /**
  56.          * @var User $user
  57.          */
  58.         $user $this->getUser();
  59.         $user_wish = (!is_null($user))?$wishrepo->countUserWishList($user->getId())["cnt"]:""
  60.         $user_bookingValue = (!is_null($user))?((float)(base64_decode($user->getBookingValue()))):"0,00"
  61.        
  62.         $error $authenticationUtils->getLastAuthenticationError();
  63.       
  64.         $lastUsername $authenticationUtils->getLastUsername();
  65.         $test1 json_decode(json_encode($currency->getCurrencyConverter1()), true);
  66.         $clearForm $this->createForm(ClearCartType::class, $order->getCurrent());
  67.         $setPaymentForm $this->createForm(SetPaymentType::class, $order->getCurrent());
  68.         $setShipmentForm $this->createForm(SetShipmentType::class, $order->getCurrent());
  69.         $setDiscountForm $this->createForm(SetDiscountType::class, $order->getCurrent());
  70.         return $this->render('dogmo/index.html.twig', [
  71.             'userWish' => $user_wish,
  72.             'bookingValue'=>$user_bookingValue,
  73.             'products' => $products,
  74.             'products_2' => $products_2,
  75.             'products_3' => $products_3,
  76.             'products_4' => $products_4,
  77.             'products_5' => $products_5,
  78.             'products_6' => $products_6,
  79.             'products_7' => $products_7,
  80.             'last_username' => $lastUsername,
  81.             'locale'=>$request->getLocale(),
  82.             'error' => $error,
  83.             'order' => $order,
  84.             'currencie_convert' => $currency->getRate($session->get('converter')),
  85.             "converter" => (!empty($session->get('converter'))) ? $session->get('converter') : "EUR",
  86.             'clearForm' => $clearForm->createView(),
  87.             'setPaymentForm' => $setPaymentForm->createView(),
  88.             'setShipmentForm' => $setShipmentForm->createView(),
  89.             'setDiscountForm' => $setDiscountForm->createView(),
  90.             'itemsInCart' => $order->getCurrent()->getItemsTotal(),
  91.             'order_cat' => $order->getCurrent()->getCart_cat(),
  92.         ]);
  93.     }
  94.     
  95.     /**
  96.      * @Route("/converter", name="convert")
  97.      * @param Request $request
  98.      * @param SessionInterface $session
  99.      * @return Response
  100.      */
  101.     public function indexConverter(Request $requestSessionInterface $session)
  102.     {
  103.         $sortbyconvert $request->request->get('sortbyconvert');
  104.         if ($request) {
  105.             $session->set('converter'$sortbyconvert);
  106.             $session->set('ville',1);
  107.             $session->get('ville');
  108.             $session->get('converter');
  109.         }
  110.         return $this->redirect($request->server->get('HTTP_REFERER'));
  111.     }
  112.     /**
  113.      * @Route("/search-product", name="search_product")
  114.      * @param Request $request
  115.      * @param SessionInterface $session
  116.      * @return Response
  117.      */
  118.     public function indexSearchProduct(Request $requestSessionInterface $session)
  119.     {
  120.         $categori2 $request->request->get('categori2');
  121.         if ($request) {
  122.             $session->set('ville'$categori2);
  123.             $session->get('ville');
  124.         }
  125.         return $this->redirectToRoute('shop_detail');
  126.     }
  127.     /**
  128.      * @Route({
  129.      *     "fr": "/Product-detail/{id}/{cat}/{img}",
  130.      *     "en": "/Product-detail/{id}/{cat}/{img}/en"
  131.      * }, name="produit-detail")
  132.      *  @param Request $request
  133.      *  @param CurrencyService $currency
  134.      *
  135.      */
  136.     public function indexDetail(Request $requestImagesRepository $imgRepositoryWishListRepository $wishrepoAnnoncesRepository $annoncesRepository$id$cat$imgCurrencyService $currencyProductRepository $productRepositoryOrderFactory $orderSessionInterface $sessionAuthenticationUtils $authenticationUtils): Response
  137.     {
  138.         $products $productRepository->findAll();
  139.         $repository $this->getDoctrine()->getRepository(Images::class);
  140.         $error $authenticationUtils->getLastAuthenticationError();
  141.       
  142.         $lastUsername $authenticationUtils->getLastUsername();
  143.         $clearForm $this->createForm(ClearCartType::class, $order->getCurrent());
  144.         $setPaymentForm $this->createForm(SetPaymentType::class, $order->getCurrent());
  145.         $setShipmentForm $this->createForm(SetShipmentType::class, $order->getCurrent());
  146.         $setDiscountForm $this->createForm(SetDiscountType::class, $order->getCurrent());
  147.         $image_prod $imgRepository->findByAnnoncesId($id);
  148.        
  149.         $img_prod_detail $imgRepository->findByAnnonceId($img);
  150.    
  151.         $locale $request->getLocale();
  152.         /**
  153.          * @var User $user
  154.          */
  155.         $user $this->getUser();
  156.     
  157.         $user_wish = (!is_null($user))?$wishrepo->countUserWishList($user->getId())["cnt"]:""
  158.         $user_bookingValue = (!is_null($user))?((float)(base64_decode($user->getBookingValue()))):"0,00"
  159.         $prod_detail $productRepository->find($id);
  160.        
  161.         if ($request->isXmlHttpRequest() && $request->isMethod('POST')) {
  162.             $cat $_POST['cat'];
  163.             $magasin $_POST['magasin'];
  164.             $currencie $_POST['currencie'];
  165.             $converter $_POST['converter'];
  166.             $locale $_POST['locale'];
  167.             if (isset($_POST['page_h_l'])) {
  168.                 $page str_replace('"'''json_encode($_POST['page_h_l']));
  169.                 $load $productRepository->loadPageLowToHigh($locale$cat,$magasin$page$converter$currencie);
  170.             } else {
  171.                 $page 0;
  172.                 $load $productRepository->loadPageLowToHigh($locale$cat,$magasin$page$converter$currencie);
  173.             }
  174.             if (isset($_POST['page_l_h'])) {
  175.                 $page str_replace('"'''json_encode($_POST['page_l_h']));
  176.                 $load $productRepository->loadPageHighToLow($locale$cat,$magasin$page$converter$currencie);
  177.             } else {
  178.                 $page 0;
  179.                 $load $productRepository->loadPageHighToLow($locale$cat,$magasin$page$converter$currencie);
  180.             }
  181.             if (isset($_POST['page_n'])) {
  182.                 $page str_replace('"'''json_encode($_POST['page_n']));
  183.                 $load $productRepository->loadPageNewste($locale$cat,$magasin$page$converter$currencie);
  184.             } else {
  185.                 $page 0;
  186.                 $load $productRepository->loadPageNewste($locale$cat,$magasin$page$converter$currencie);
  187.             }
  188.             return new JsonResponse($load);
  189.         } else {
  190.             $currenc = (!empty($session->get('converter'))) ? $session->get('converter') : "EUR";
  191.             $highPrice $productRepository->searchHighAmount($cat);
  192.             $lowPrice $productRepository->searchLowAmount($cat);
  193.             return $this->render('home/product-sidebar.html.twig', [
  194.                 'error' => $error,
  195.                 'last_username' => $lastUsername,
  196.                 'prod_id' => $prod_detail->getId(),
  197.                 'prod_name' => $prod_detail->getName(),
  198.                 'prod_price' => $prod_detail->getPrice(),
  199.                 'prod_content' => $prod_detail->getContent(),
  200.                 'prod_image' => $prod_detail->getImage(),
  201.                 'cart_cat' => $prod_detail->getCart_cat(),
  202.                 'annonce_id' => $prod_detail->getUser_id(),
  203.                 'img_prod_details' => $img_prod_detail,
  204.                 'userWish' => $user_wish,
  205.                 'bookingValue'=>$user_bookingValue,
  206.                 'order_cat' => $order->getCurrent()->getCart_cat(),
  207.                 'products_shop' => $productRepository->loadPageDetail($locale$cat100,0$currenc$currency->getRate($session->get('converter'))),
  208.                 'highPrice' => $highPrice[0]["price"],
  209.                 'lowPrice' => $lowPrice[0]["price"],
  210.                 'cat' => $cat,
  211.                 'currencie_convert' => $currency->getRate($session->get('converter')),
  212.                 "converter" => (!empty($session->get('converter'))) ? $session->get('converter') : "EUR",
  213.                 'products' => $products,
  214.                 'order' => $order,
  215.                 'clearForm' => $clearForm->createView(),
  216.                 'setPaymentForm' => $setPaymentForm->createView(),
  217.                 'setShipmentForm' => $setShipmentForm->createView(),
  218.                 'setDiscountForm' => $setDiscountForm->createView(),
  219.                 'itemsInCart' => $order->getCurrent()->getItemsTotal(),
  220.             ]);
  221.         }
  222.     }
  223.     /**
  224.      * @Route({
  225.      *     "fr": "/shop-detail",
  226.      *     "en": "/shop-detail/en"
  227.      * },name="shop_detail" , methods={"GET","POST"})
  228.      *  @param Request $request
  229.      *  @param SessionInterface $session
  230.      *  @param CurrencyService $currency
  231.      *
  232.      */
  233.     public function shopDetail(Request $requestProductRepository $productRepositoryWishListRepository $wishrepoOrderFactory $orderCurrencyService $currencySessionInterface $sessionAuthenticationUtils $authenticationUtils): Response
  234.     {
  235.         $ville = !empty($request->request->get('categori2'))?$request->request->get('categori2'):1;
  236.         $magasin $request->request->get('select_magasin'); 
  237.         if ($ville == "Choisir une ville") {
  238.             $this->addFlash('error''Vous devez choisir une ville et ensuite un magasin dans cette ville!');           
  239.             $referer $request->headers->get('referer');
  240.             return $this->redirect($referer);
  241.         }
  242.      
  243.        
  244.         $session->set('cat_c1'$ville);
  245.         $session->get('cat_c1');
  246.         $locale $request->getLocale();
  247.       
  248.         $villeName = [=> "Douala"=> "Yaoundé"=> "Bafoussam"=> "Mbouda"10 => ""];
  249.         $magasinVille = [=> [=> "Supermarché Santa Lucia Ange Raphael"=> "Supermarché Dovy Douala"=> "Supermarché Dovy Douala"=> "Supermarché KDO Douala"10 => "",0=>""] , => [=> "Supermarché Santa Lucia Yaoundé"=> "Supermarché Dovy Yaoundé"=> "Supermarché KDO Yaoundé"=> "Supermarché KDO Yaoundé"10 => "",0=>""] , => [=> "Supermarché Santa Lucia Bafoussam"=> "Supermarché Dovy Bafoussam"=> "Supermarché KDO Bafoussam"=> "Supermarché KDO Bafoussam"10 => "",0=>""], => [=> "Supermarché Santa Lucia Dschang"=> "Supermarché Dovy Dschang"=> "Supermarché Dovy Dschang"=> "Supermarché KDO Dschang"=> "",0=>""], => [=> "Supermarché Santa Lucia Mbouda"=> "Supermarché Dovy Mbouda"=> "Supermarché Dovy Mbouda"=> "Supermarché KDO Mbouda"10 => "",0=>""]];
  250.         
  251.         /**
  252.          * @var User $user
  253.          */
  254.         $user $this->getUser();
  255.        
  256.         $user_wish = (!is_null($user))?$wishrepo->countUserWishList($user->getId())["cnt"]:""
  257.         $user_bookingValue = (!is_null($user))?((float)(base64_decode($user->getBookingValue()))):"0,00"
  258.         $cat= [$ville];
  259.         $error $authenticationUtils->getLastAuthenticationError();
  260.        
  261.         $lastUsername $authenticationUtils->getLastUsername();
  262.         $clearForm $this->createForm(ClearCartType::class, $order->getCurrent());
  263.         $setPaymentForm $this->createForm(SetPaymentType::class, $order->getCurrent());
  264.         $setShipmentForm $this->createForm(SetShipmentType::class, $order->getCurrent());
  265.         $setDiscountForm $this->createForm(SetDiscountType::class, $order->getCurrent());
  266.         if ($request->isXmlHttpRequest() && $request->isMethod('POST')) {
  267.             $cat $_POST['cat'];
  268.             $magasin $_POST['magasin'];
  269.             $currencie $_POST['currencie'];
  270.             $converter $_POST['converter'];
  271.             $locale $_POST['locale'];
  272.             if (isset($_POST['page_no'])) {
  273.                 $page str_replace('"'''json_encode($_POST['page_no']));
  274.                 $load $productRepository->loadPage($locale$cat,$magasin$page$converter$currencie);
  275.             } else {
  276.                 $page 0;
  277.                 $load $productRepository->loadPage($locale$cat$magasin$page$converter$currencie);
  278.             }
  279.             if (isset($_POST['page_h_l'])) {
  280.                 $page str_replace('"'''json_encode($_POST['page_h_l']));
  281.                 $load $productRepository->loadPageLowToHigh($locale$cat,$magasin$page$converter$currencie);
  282.             }
  283.             if (isset($_POST['page_l_h'])) {
  284.                 $page str_replace('"'''json_encode($_POST['page_l_h']));
  285.                 $load $productRepository->loadPageHighToLow($locale$cat,$magasin$page$converter$currencie);
  286.             }
  287.             if (isset($_POST['page_n'])) {
  288.                 $page str_replace('"'''json_encode($_POST['page_n']));
  289.                 $load $productRepository->loadPageNewste($locale$cat,$magasin$page$converter$currencie);
  290.             }
  291.             return new JsonResponse($load);
  292.         } else {
  293.             $session->set('highPrice_value'$productRepository->searchHighAmount($session->get('cat_c1'))[0]["price"]);
  294.             $session->set('lowPrice_value'$productRepository->searchLowAmount($session->get('cat_c1'))[0]["price"]);
  295.     
  296.             $currenc = (!empty($session->get('converter'))) ? $session->get('converter') : "EUR";
  297.           
  298.             return $this->render('home/shop-detail.html.twig', [
  299.                 'userWish' => $user_wish,
  300.                 'bookingValue'=>$user_bookingValue,
  301.                 'highPrice' => $session->get('highPrice_value'),
  302.                 'lowPrice' => $session->get('lowPrice_value'),
  303.                 'order' => $order,
  304.                 'error' => $error,
  305.                 'villeMagsin'=> ($magasinVille[$ville][$magasin])?$magasinVille[$ville][$magasin] : $magasinVille[1][0],
  306.                 'last_username' => $lastUsername,
  307.                 'products_shop' => '',
  308.                 'currencie_convert' => $currency->getRate($session->get('converter')),
  309.                 "converter" => (!empty($session->get('converter'))) ? $session->get('converter') : "EUR",
  310.                 'locale' => $request->getLocale(),
  311.                 'clearForm' => $clearForm->createView(),
  312.                 'cat' => $cat,
  313.                 'ville'=>$session->get('cat_c1') ,
  314.                 'magasin' => $magasin,
  315.                 'order_cat' => $order->getCurrent()->getCart_cat(),
  316.                 'setPaymentForm' => $setPaymentForm->createView(),
  317.                 'setShipmentForm' => $setShipmentForm->createView(),
  318.                 'setDiscountForm' => $setDiscountForm->createView(),
  319.                 'itemsInCart' => $order->getCurrent()->getItemsTotal(),
  320.             ]);
  321.         }
  322.     }
  323.     /**
  324.      * @Route({
  325.      *     "fr": "/shop-detail/{ville}/{magasin}/{categorie}/{type}",
  326.      *     "en": "/shop-detail/{ville}/{magasin}/{categorie}/{type}/en"
  327.      * },name="shop_detail_ville" )
  328.      *  @param Request $request
  329.      *  @param SessionInterface $session
  330.      *  @param CurrencyService $currency
  331.      *
  332.      */
  333.     public function shopDetailVille(Request $request$ville$magasin$type$categorieProductRepository $productRepositoryWishListRepository $wishrepoOrderFactory $orderCurrencyService $currencySessionInterface $sessionAuthenticationUtils $authenticationUtils): Response
  334.     {
  335.       
  336.         if ($ville == "Choisir une ville") {
  337.             $this->addFlash('error''Vous devez choisir une ville et ensuite un magasin dans cette ville!');
  338.             
  339.             $referer $request->headers->get('referer');
  340.             return $this->redirect($referer);
  341.         }
  342.      
  343.         $session->set('cat_c1'$ville);
  344.         $session->get('cat_c1');
  345.         $locale $request->getLocale();
  346.    
  347.         $villeName = [=> "Douala"=> "Yaoundé"=> "Bafoussam"=> "Mbouda"10 => ""];
  348.         $magasinVille = [=> [0=> $this->translator->trans('app.home.africa_shopping_ville')." douala "=>  $this->translator->trans('app.home.africa_shopping_supermarkt')." Santa Lucia Ange Raphael"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Dovy Douala"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Dovy Douala"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  KDO Douala"10 => ""] , => [0=>$this->translator->trans('app.home.africa_shopping_ville')." yaoundé ",=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Santa Lucia Yaoundé"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Dovy Yaoundé"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  KDO Yaoundé"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  KDO Yaoundé"10 => ""] , => [0=>$this->translator->trans('app.home.africa_shopping_ville')." bafoussam ",=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Santa Lucia Bafoussam"=>$this->translator->trans('app.home.africa_shopping_supermarkt')."  Dovy Bafoussam"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  KDO Bafoussam"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  KDO Bafoussam"10 => ""], => [0=>$this->translator->trans('app.home.africa_shopping_ville')." dschang ",=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Santa Lucia Dschang"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Dovy Dschang"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Dovy Dschang"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  KDO Dschang"=> ""], => [0=>$this->translator->trans('app.home.africa_shopping_ville')." mbouda ",=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Santa Lucia Mbouda"=> $this->translator->trans('app.home.africa_shopping_supermarkt')." Dovy Mbouda"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  Dovy Mbouda"=> $this->translator->trans('app.home.africa_shopping_supermarkt')."  KDO Mbouda"10 => ""]];
  349.         
  350.         /**
  351.          * @var User $user
  352.          */
  353.         $user $this->getUser();
  354.      
  355.         $user_wish = (!is_null($user))?$wishrepo->countUserWishList($user->getId())["cnt"]:""
  356.         $user_bookingValue = (!is_null($user))?((float)(base64_decode($user->getBookingValue()))):"0,00"
  357.   
  358.         $cat= [$ville];
  359.         $error $authenticationUtils->getLastAuthenticationError();
  360.         $lastUsername $authenticationUtils->getLastUsername();
  361.         $clearForm $this->createForm(ClearCartType::class, $order->getCurrent());
  362.         $setPaymentForm $this->createForm(SetPaymentType::class, $order->getCurrent());
  363.         $setShipmentForm $this->createForm(SetShipmentType::class, $order->getCurrent());
  364.         $setDiscountForm $this->createForm(SetDiscountType::class, $order->getCurrent());
  365.         if ($request->isXmlHttpRequest() && $request->isMethod('POST')) {
  366.             $cat $_POST['cat'];
  367.             $currencie $_POST['currencie'];
  368.             $converter $_POST['converter'];
  369.             $locale $_POST['locale'];
  370.             if (isset($_POST['page_no'])) {
  371.                 $page str_replace('"'''json_encode($_POST['page_no']));
  372.                 $load $productRepository-> loadPage($locale$cat$magasin$page$converter$currencie);
  373.             } else {
  374.                 $page 0;
  375.                 $load $productRepository->loadPage($locale$cat$magasin$page$converter$currencie);
  376.                
  377.             }
  378.             if (isset($_POST['page_h_l'])) {
  379.                 $page str_replace('"'''json_encode($_POST['page_h_l']));
  380.                 $load $productRepository->loadPageLowToHigh($locale$cat,$magasin$page$converter$currencie);
  381.             }
  382.             if (isset($_POST['page_l_h'])) {
  383.                 $page str_replace('"'''json_encode($_POST['page_l_h']));
  384.                 $load $productRepository->loadPageHighToLow($locale$cat,$magasin$page$converter$currencie);
  385.             }
  386.             if (isset($_POST['page_n'])) {
  387.                 $page str_replace('"'''json_encode($_POST['page_n']));
  388.                 $load $productRepository->loadPageNewste($locale$cat,$magasin$page$converter$currencie);
  389.             }
  390.             return new JsonResponse($load);
  391.         } else {
  392.             $session->set('highPrice_value'$productRepository->searchHighAmount($session->get('cat_c1'))[0]["price"]);
  393.             $session->set('lowPrice_value'$productRepository->searchLowAmount($session->get('cat_c1'))[0]["price"]);
  394.     
  395.             $currenc = (!empty($session->get('converter'))) ? $session->get('converter') : "EUR";
  396.         
  397.             return $this->render('home/shop-detail.html.twig', [
  398.                 'userWish' => $user_wish,
  399.                 'bookingValue'=>$user_bookingValue,
  400.                 'highPrice' => $session->get('highPrice_value'),
  401.                 'lowPrice' => $session->get('lowPrice_value'),
  402.                 'order' => $order,
  403.                 'error' => $error,
  404.                 'villeMagsin'=> $magasinVille[$ville][$magasin],
  405.                 'last_username' => $lastUsername,
  406.                 'products_shop' => $productRepository->loadPageDetail($locale$ville40$categorie$type$currenc$currency->getRate($session->get('converter'))),
  407.                 'currencie_convert' => $currency->getRate($session->get('converter')),
  408.                 "converter" => (!empty($session->get('converter'))) ? $session->get('converter') : "EUR",
  409.                 'locale' => $request->getLocale(),
  410.                 'clearForm' => $clearForm->createView(),
  411.                 'cat' => $cat,
  412.                 'magasin' => $magasin,
  413.                 'categorie' => $categorie,
  414.                 'type' => $type,
  415.                 'ville' =>$ville,
  416.                 'order_cat' => $order->getCurrent()->getCart_cat(),
  417.                 'setPaymentForm' => $setPaymentForm->createView(),
  418.                 'setShipmentForm' => $setShipmentForm->createView(),
  419.                 'setDiscountForm' => $setDiscountForm->createView(),
  420.                 'itemsInCart' => $order->getCurrent()->getItemsTotal(),
  421.             ]);
  422.         }
  423.     }
  424.     /**
  425.      * @Route("/setsearch", name="search_page", methods={"POST"})
  426.      */
  427.     public function setSearchPage(Request $requestProductRepository $productRepository)
  428.     {
  429.        
  430.         $cat $_POST['cat'];
  431.         $currencie $_POST['currencie'];
  432.         $converter $_POST['converter'];
  433.         $locale $_POST['locale'];
  434.         $datasearch str_replace('"'''json_encode($_POST['query']));
  435.         
  436.         $searchpage $productRepository->searchPage($datasearch$cat);
  437.        
  438.         $jsonDatax = [];
  439.         $idx 0;
  440.         $currency = [];
  441.         $currency["EUR"] = "€";
  442.         $currency["USD"] = "$";
  443.         $currency["GBP"] = "£";
  444.         $currency["CAD"] = "c$";
  445.         $currency["XAF"] = "FCFA";
  446.         for ($i 0$i count($searchpage); $i++){
  447.             $temp = [
  448.                 'name' => $searchpage[$i]['name'],
  449.                 'cart_cat' => $searchpage[$i]['cart_cat'],
  450.                 'type' => $searchpage[$i]['type'],
  451.                 'type1' => $searchpage[$i]['type1'],
  452.                 'id' => $searchpage[$i]['id'],
  453.                 'currencie' => $currency[$converter],
  454.                 'image' => $searchpage[$i]['image'],
  455.                 'price' => ($currencie == 'EUR') ? $searchpage[$i]['price'] : (number_format($searchpage[$i]['price'] * $currencie2','' ')),
  456.             ];
  457.             $jsonDatax[$idx++] = $temp;
  458.         }
  459.         return new JsonResponse($jsonDatax);
  460.     }
  461.     /**
  462.      * @Route("/setslider", name="searchslider", methods={"POST"})
  463.      */
  464.     public function setSearchSlider(Request $requestProductRepository $productRepository)
  465.     {
  466.         $cat $_POST['cat'];
  467.         $currencie $_POST['currencie'];
  468.         $converter $_POST['converter'];
  469.         $locale $_POST['locale'];
  470.         if (isset($_POST['minAge'])) {
  471.             $minAge str_replace('"'''json_encode($_POST['minAge']));
  472.             $maxAge str_replace('"'''json_encode($_POST['maxAge']));
  473.             $load $productRepository->loadSlider($minAge$maxAge$locale$cat$converter$currencie);
  474.         }else{
  475.             $minAge 10;
  476.             $maxAge 1234;
  477.             $load $productRepository->loadSlider($minAge$maxAge$locale$cat$converter$currencie);
  478.         }
  479.         return new JsonResponse($load);
  480.     }
  481. }