src/Controller/EntrepriseController.php line 30

Open in your IDE?
  1. <?php
  2. // src/Controller/EntrepriseController.php
  3. namespace App\Controller;
  4. use App\Entity\Photo;
  5. use App\Entity\Famille;
  6. use App\Entity\CategoriePhoto;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. /**
  12.  * @Route("/")
  13.  */
  14. class EntrepriseController extends AbstractController
  15. {    
  16.         private $session;
  17.     
  18.     public function __construct(SessionInterface $session)
  19.         {
  20.             $this->session = $session;
  21.         }
  22.         /**
  23.         * @Route("/", name="home_first")
  24.         */
  25.         public function homeFirstAction()
  26.         {
  27.                 $em = $this->getDoctrine()
  28.                     ->getManager();
  29.                 $familles = $this->donneesAccueil();
  30.         return $this->render('entreprise/accueil.html.twig', [
  31.             
  32.                         'familles' => json_encode($familles)
  33.                 ]);
  34.     }
  35.     
  36.     /**
  37.         * @Route("/{_locale}", name="home")
  38.         */
  39.         public function homeAction()
  40.         {
  41.              $familles = $this->donneesAccueil();
  42.         return $this->render('entreprise/accueil.html.twig', [
  43.                         'familles' => json_encode($familles),
  44.                 ]);
  45.     }
  46.         /**
  47.         * @Route("/{_locale}/nos-produits", name="nos_produits")
  48.         */
  49.         public function nosProduitsAction()
  50.         {
  51.              $familles = $this->donneesAccueil();
  52.         return $this->render('entreprise/nos_produits.html.twig', [
  53.                         'familles' => json_encode($familles),
  54.                 ]);
  55.     }
  56.         /**
  57.         * @Route("/{_locale}/galerie", name="galerie")
  58.         */
  59.         public function gzlerieAction()
  60.         {
  61.         return $this->render('entreprise/galerie.html.twig', [
  62.                         
  63.                 ]);
  64.     }
  65.         /**
  66.         * @Route("/{_locale}/a-propos", name="a_propos")
  67.         */
  68.         public function aProposAction()
  69.         {
  70.                
  71.         return $this->render('entreprise/a_propos.html.twig', [
  72.                    
  73.                 ]);
  74.     }
  75.         
  76.         /**
  77.         * @Route("/{_locale}/devis", name="devis")
  78.         */
  79.         public function devisAction()
  80.         {        $familles = $this->donneesAccueil();
  81.         return $this->render('entreprise/devis.html.twig', [
  82.                            'familles' => $familles  
  83.                 ]);
  84.     }
  85.         
  86.         
  87.     
  88.     
  89.     public function donneesAccueil()
  90.         {
  91.                 $em = $this->getDoctrine()
  92.                     ->getManager();
  93.                $familles = $em->getRepository(Famille::class)
  94.                                 ->findAll();
  95.                 $fs = array();
  96.                 foreach($familles as $famille){
  97.                         $categories = array();
  98.                         foreach($famille->getCategories() as $categorie){
  99.                                 $c = array(
  100.                                         'nom' => $categorie->getNom(),
  101.                                         'image' => ($categorie->getImage() !== null)?$categorie->getImage()->getUrl():''
  102.                                 );
  103.                                 array_push($categories, $c);
  104.                         }
  105.                         $f = array(
  106.                                 'id' => $famille->getSlug(),
  107.                                 'nom' => $famille->getNom(),
  108.                                 'icone' => $famille->getIcone(),
  109.                                 'description' => $famille->getDescription(),
  110.                                 'image' => ($famille->getImage() !== null)?$famille->getImage()->getUrl():'',
  111.                                 'categories' => $categories
  112.                         );
  113.                         array_push($fs, $f);
  114.                 }
  115.                 return $fs;
  116.         }
  117.         /**
  118.         * @Route("/{_locale}/contact", name="contact")
  119.         */
  120.         public function contactAction()
  121.         {
  122.         
  123.             return $this->render('entreprise/contact.html.twig', [
  124.             
  125.                 ]);
  126.     }
  127. }