src\Controller\FrontController.php line 78

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller;
  4. use App\Handler\ContactHandler;
  5. use App\Handler\RegisterHandler;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Twig\Error\LoaderError;
  10. use Twig\Error\RuntimeError;
  11. use Twig\Error\SyntaxError;
  12. /**
  13.  * Class FrontController.
  14.  *
  15.  * @Route("", name="front_", options={"sitemap": true})
  16.  */
  17. final class FrontController extends AbstractController
  18. {
  19.     /**
  20.      * @var RegisterHandler
  21.      */
  22.     private $registerHandler;
  23.     /**
  24.      * @var ContactHandler
  25.      */
  26.     private $contactHandler;
  27.     /**
  28.      * FrontController constructor.
  29.      */
  30.     public function __construct(RegisterHandler $registerHandlerContactHandler $contactHandler)
  31.     {
  32.         $this->registerHandler $registerHandler;
  33.         $this->contactHandler $contactHandler;
  34.     }
  35.     /**
  36.      * @Route("/", name="index", options={"sitemap": true})
  37.      *
  38.      * @throws RuntimeError
  39.      * @throws SyntaxError
  40.      * @throws LoaderError
  41.      */
  42.     public function index(): Response
  43.     {
  44.         $result $this->registerHandler->process();
  45.         return !is_null($this->getUser())
  46.             ? $this->redirectToRoute('espace_client_index')
  47.             : $this->redirectToRoute('security_login');
  48.     }
  49.     /**
  50.      * @Route("/contact/", name="contact", options={"sitemap": true})
  51.      *
  52.      * @throws RuntimeError
  53.      * @throws SyntaxError
  54.      * @throws LoaderError
  55.      */
  56.     public function contact(): Response
  57.     {
  58.         $this->contactHandler->process();
  59.         return $this->contactHandler->getEmailState() > 0
  60.             $this->redirectToRoute('front_contact')
  61.             : $this->render('front/contact.html.twig', [
  62.                 'form' => $this->contactHandler->getForm()->createView(),
  63.             ]);
  64.     }
  65.     /**
  66.      * @Route("/mentions-legales/", name="legalnotice", options={"sitemap": true})
  67.      */
  68.     public function legalNotice(): Response
  69.     {
  70.         return $this->render('front/legal-notice.html.twig');
  71.     }
  72.     /**
  73.      * @Route("/tarifs-et-services/", name="servicesprices", options={"sitemap": true})
  74.      */
  75.     public function services_prices(): Response
  76.     {
  77.         return $this->redirect($_ENV['WORDPRESS_WEBSITE_PATH'] . '/nos-tarifs/');
  78.     }
  79.     /**
  80.      * @Route("/services/", name="services", options={"sitemap": true})
  81.      */
  82.     public function services(): Response
  83.     {
  84.         return $this->redirect($_ENV['WORDPRESS_WEBSITE_PATH'] . '/services-fiscaux/');
  85.     }
  86.     /**
  87.      * @Route("/qui-nous-sommes/", name="who_we_are", options={"sitemap": true})
  88.      */
  89.     public function whoWeAre(): Response
  90.     {
  91.         return $this->redirect($_ENV['WORDPRESS_WEBSITE_PATH'] . '/qui-sommes-nous/');
  92.     }
  93.     /**
  94.      * @Route("/retour/vers/pitaxes/", name="back_to_wordpress", options={"sitemap": true})
  95.      */
  96.     public function back_to_wordpress(): Response
  97.     {
  98.         return $this->redirect($_ENV['WORDPRESS_WEBSITE_PATH']);
  99.     }
  100. }