src/Controller/HomeController.php line 23
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Repository\CategorieRepository;
use App\Repository\ParamaccueilRepository;
use App\Repository\ParamRepository;
use App\Repository\ProduitRepository;
use App\Repository\MarqueRepository;
use App\Repository\PageRepository;
use App\Entity\Paramaccueil;
use App\Entity\Produit;
use App\Entity\Page;
use DeviceDetector\DeviceDetector;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class HomeController extends AbstractController
{
#[Route('/', name: 'app_home')]
public function index(CategorieRepository $categorierep, ManagerRegistry $doctrine, MarqueRepository $marquerep, ParamaccueilRepository $parama, ProduitRepository $produitrep): Response
{
$dd = new DeviceDetector($_SERVER['HTTP_USER_AGENT']);
$dd->parse();
$repaccueil = $doctrine->getRepository(Paramaccueil::class);
$param = $repaccueil->findOneBy([],[]);
$mobile = $dd->isSmartphone();
$tablet = $dd->isTablet();
$categories = $categorierep->findCategorieHome();
$topcategories = $categorierep->CategoriesAccueil();
$marques = $marquerep->HomeMarques();
$parama = $parama->findOneBy([], []);
$produitspop = $produitrep->getProduitsPop();
$produitspromo = $produitrep->getProduitsPromo();
return $this->render('home/index.html.twig', [
'parama' => $parama,
'categories' => $categories,
'mobile' => $mobile,
'produitspop' => $produitspop,
'marques' => $marques,
'topcategories' => $topcategories,
'produitspromo' => $produitspromo,
'param' => $param,
]);
}
#[Route('/header', name: 'app_header')]
public function app_header(CategorieRepository $categorierep, ParamRepository $paramrep, SessionInterface $session): Response
{
$dd = new DeviceDetector($_SERVER['HTTP_USER_AGENT']);
$dd->parse();
$mobile = $dd->isSmartphone();
$tablet = $dd->isTablet();
$categories = $categorierep->findCategorieP();
$param = $paramrep->findOneBy([], []);
if($session->get('panier') != null)
{
$nbre = (count($session->get('panier')));
}
else
{
$nbre = 0;
}
return $this->render('home/header.html.twig', [
'param' => $param,
'categories' => $categories,
'mobile' => $mobile,
'nbre' => $nbre,
]);
}
#[Route('/footer', name: 'app_footer')]
public function app_footer(ParamRepository $paramrep, PageRepository $pagerep, CategorieRepository $categorieRepository): Response
{
$dd = new DeviceDetector($_SERVER['HTTP_USER_AGENT']);
$dd->parse();
$mobile = $dd->isSmartphone();
$tablet = $dd->isTablet();
$param = $paramrep->findOneBy([], []);
$pages = $pagerep->findBy([], []);
$categories = $categorieRepository->CategoriesFooter();
return $this->render('footer.html.twig', [
'param' => $param,
'mobile' => $mobile,
'pages' => $pages,
'categories' => $categories,
]);
}
#[Route('/page/{slug}', name: 'app_page')]
public function app_page(ParamRepository $paramrep, Page $page): Response
{
$dd = new DeviceDetector($_SERVER['HTTP_USER_AGENT']);
$dd->parse();
$mobile = $dd->isSmartphone();
$tablet = $dd->isTablet();
$param = $paramrep->findOneBy([], []);
return $this->render('footer.html.twig', [
'param' => $param,
'mobile' => $mobile,
'page' => $page,
]);
}
#[Route('/vuerapide/{id}', name: 'vuerapide')]
public function vuerapide(Produit $produit): Response
{
return $this->render('content/vuerapide.html.twig', [
'produit' => $produit,
]);
}
}