src/Controller/FrontController.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Configuration;
  4. use App\Repository\ConfigurationRepository;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. class FrontController extends AbstractController
  9. {
  10.     private ConfigurationRepository $configurationRepository;
  11.     public function __construct(ConfigurationRepository $configurationRepository)
  12.     {
  13.       $this->configurationRepository = $configurationRepository;
  14.     }
  15.     /**
  16.      * Récupère l'objet Configuration en bdd
  17.      *
  18.      * @return Configuration
  19.      */
  20.     public function getConfiguration(): Configuration
  21.     {
  22.         return $this->configurationRepository->findOneBy(['uuid' => Configuration::UNIQUE_UUID]);
  23.     }
  24.     
  25.     /**
  26.      * @param  mixed $userRepository
  27.      * @return Response
  28.      * @Route("/", name="home", methods={"GET","POST"})
  29.      */
  30.     public function index(): Response
  31.     {
  32.         return $this->render('front/index.html.twig', []);
  33.     }
  34.     /**
  35.      * @Route("/css_route", name="css_route")
  36.      */
  37.     public function css_route(): Response
  38.     {
  39.         $configuration = $this->getConfiguration();
  40.         $response = $this->render('front/style.css.twig', [
  41.             'configuration' => $configuration,
  42.         ]);
  43.         $response->headers->set('Content-Type', 'text/css');
  44.         return $response;
  45.     }
  46. }