src/Controller/HomeController.php line 23

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Repository\CategorieRepository;
  7. use App\Repository\ParamaccueilRepository;
  8. use App\Repository\ParamRepository;
  9. use App\Repository\ProduitRepository;
  10. use App\Repository\MarqueRepository;
  11. use App\Repository\PageRepository;
  12. use App\Entity\Paramaccueil;
  13. use App\Entity\Produit;
  14. use App\Entity\Page;
  15. use DeviceDetector\DeviceDetector;
  16. use Doctrine\Persistence\ManagerRegistry;
  17. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  18. class HomeController extends AbstractController
  19. {
  20.     #[Route('/'name'app_home')]
  21.     public function index(CategorieRepository $categorierepManagerRegistry $doctrineMarqueRepository $marquerepParamaccueilRepository $paramaProduitRepository $produitrep): Response
  22.     {
  23.         $dd = new DeviceDetector($_SERVER['HTTP_USER_AGENT']);
  24.         $dd->parse();
  25.         $repaccueil $doctrine->getRepository(Paramaccueil::class);
  26.         $param $repaccueil->findOneBy([],[]);
  27.         $mobile $dd->isSmartphone();
  28.         $tablet $dd->isTablet();
  29.         $categories $categorierep->findCategorieHome();
  30.         $topcategories $categorierep->CategoriesAccueil();
  31.         $marques $marquerep->HomeMarques();
  32.         $parama $parama->findOneBy([], []);
  33.         $produitspop $produitrep->getProduitsPop();
  34.         $produitspromo $produitrep->getProduitsPromo();
  35.         return $this->render('home/index.html.twig', [
  36.             'parama' => $parama,
  37.             'categories' => $categories,
  38.             'mobile' => $mobile,
  39.             'produitspop' => $produitspop,
  40.             'marques' => $marques,
  41.             'topcategories' => $topcategories,
  42.             'produitspromo' => $produitspromo,
  43.             'param' => $param,
  44.         ]);
  45.     }
  46.     #[Route('/header'name'app_header')]
  47.     public function app_header(CategorieRepository $categorierepParamRepository $paramrepSessionInterface $session): Response
  48.     {
  49.         $dd = new DeviceDetector($_SERVER['HTTP_USER_AGENT']);
  50.         $dd->parse();
  51.         $mobile $dd->isSmartphone();
  52.         $tablet $dd->isTablet();
  53.         $categories $categorierep->findCategorieP();
  54.         $param $paramrep->findOneBy([], []);
  55.         if($session->get('panier') != null)
  56.         {
  57.         $nbre = (count($session->get('panier')));
  58.         }
  59.         else
  60.         {
  61.         $nbre 0;
  62.         }
  63.         return $this->render('home/header.html.twig', [
  64.             'param' => $param,
  65.             'categories' => $categories,
  66.             'mobile' => $mobile,
  67.             'nbre' => $nbre,
  68.         ]);
  69.     }
  70.     #[Route('/footer'name'app_footer')]
  71.     public function app_footer(ParamRepository $paramrepPageRepository $pagerepCategorieRepository $categorieRepository): Response
  72.     {
  73.         $dd = new DeviceDetector($_SERVER['HTTP_USER_AGENT']);
  74.         $dd->parse();
  75.         $mobile $dd->isSmartphone();
  76.         $tablet $dd->isTablet();
  77.         $param $paramrep->findOneBy([], []);
  78.         $pages $pagerep->findBy([], []);
  79.         $categories $categorieRepository->CategoriesFooter();
  80.         return $this->render('footer.html.twig', [
  81.             'param' => $param,
  82.             'mobile' => $mobile,
  83.             'pages' => $pages,
  84.             'categories' => $categories,
  85.         ]);
  86.     }
  87.     #[Route('/page/{slug}'name'app_page')]
  88.     public function app_page(ParamRepository $paramrepPage $page): Response
  89.     {
  90.         $dd = new DeviceDetector($_SERVER['HTTP_USER_AGENT']);
  91.         $dd->parse();
  92.         $mobile $dd->isSmartphone();
  93.         $tablet $dd->isTablet();
  94.         $param $paramrep->findOneBy([], []);
  95.         return $this->render('footer.html.twig', [
  96.             'param' => $param,
  97.             'mobile' => $mobile,
  98.             'page' => $page,
  99.         ]);
  100.     }
  101.     #[Route('/vuerapide/{id}'name'vuerapide')]
  102.     public function vuerapide(Produit $produit): Response
  103.     {
  104.         return $this->render('content/vuerapide.html.twig', [
  105.             'produit' => $produit,
  106.         ]);
  107.     }
  108. }