<?php
namespace App\Controller;
use App\Entity\Configuration;
use App\Repository\ConfigurationRepository;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class FrontController extends AbstractController
{
private ConfigurationRepository $configurationRepository;
public function __construct(ConfigurationRepository $configurationRepository)
{
$this->configurationRepository = $configurationRepository;
}
/**
* Récupère l'objet Configuration en bdd
*
* @return Configuration
*/
public function getConfiguration(): Configuration
{
return $this->configurationRepository->findOneBy(['uuid' => Configuration::UNIQUE_UUID]);
}
/**
* @param mixed $userRepository
* @return Response
* @Route("/", name="home", methods={"GET","POST"})
*/
public function index(): Response
{
return $this->render('front/index.html.twig', []);
}
/**
* @Route("/css_route", name="css_route")
*/
public function css_route(): Response
{
$configuration = $this->getConfiguration();
$response = $this->render('front/style.css.twig', [
'configuration' => $configuration,
]);
$response->headers->set('Content-Type', 'text/css');
return $response;
}
}