<?php
// src/Controller/EntrepriseController.php
namespace App\Controller;
use App\Entity\Photo;
use App\Entity\Famille;
use App\Entity\CategoriePhoto;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/**
* @Route("/")
*/
class EntrepriseController extends AbstractController
{
private $session;
public function __construct(SessionInterface $session)
{
$this->session = $session;
}
/**
* @Route("/", name="home_first")
*/
public function homeFirstAction()
{
$em = $this->getDoctrine()
->getManager();
$familles = $this->donneesAccueil();
return $this->render('entreprise/accueil.html.twig', [
'familles' => json_encode($familles)
]);
}
/**
* @Route("/{_locale}", name="home")
*/
public function homeAction()
{
$familles = $this->donneesAccueil();
return $this->render('entreprise/accueil.html.twig', [
'familles' => json_encode($familles),
]);
}
/**
* @Route("/{_locale}/nos-produits", name="nos_produits")
*/
public function nosProduitsAction()
{
$familles = $this->donneesAccueil();
return $this->render('entreprise/nos_produits.html.twig', [
'familles' => json_encode($familles),
]);
}
/**
* @Route("/{_locale}/galerie", name="galerie")
*/
public function gzlerieAction()
{
return $this->render('entreprise/galerie.html.twig', [
]);
}
/**
* @Route("/{_locale}/a-propos", name="a_propos")
*/
public function aProposAction()
{
return $this->render('entreprise/a_propos.html.twig', [
]);
}
/**
* @Route("/{_locale}/devis", name="devis")
*/
public function devisAction()
{ $familles = $this->donneesAccueil();
return $this->render('entreprise/devis.html.twig', [
'familles' => $familles
]);
}
public function donneesAccueil()
{
$em = $this->getDoctrine()
->getManager();
$familles = $em->getRepository(Famille::class)
->findAll();
$fs = array();
foreach($familles as $famille){
$categories = array();
foreach($famille->getCategories() as $categorie){
$c = array(
'nom' => $categorie->getNom(),
'image' => ($categorie->getImage() !== null)?$categorie->getImage()->getUrl():''
);
array_push($categories, $c);
}
$f = array(
'id' => $famille->getSlug(),
'nom' => $famille->getNom(),
'icone' => $famille->getIcone(),
'description' => $famille->getDescription(),
'image' => ($famille->getImage() !== null)?$famille->getImage()->getUrl():'',
'categories' => $categories
);
array_push($fs, $f);
}
return $fs;
}
/**
* @Route("/{_locale}/contact", name="contact")
*/
public function contactAction()
{
return $this->render('entreprise/contact.html.twig', [
]);
}
}