<?php
declare(strict_types=1);
namespace App\Controller;
use App\Handler\ContactHandler;
use App\Handler\RegisterHandler;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
/**
* Class FrontController.
*
* @Route("", name="front_", options={"sitemap": true})
*/
final class FrontController extends AbstractController
{
/**
* @var RegisterHandler
*/
private $registerHandler;
/**
* @var ContactHandler
*/
private $contactHandler;
/**
* FrontController constructor.
*/
public function __construct(RegisterHandler $registerHandler, ContactHandler $contactHandler)
{
$this->registerHandler = $registerHandler;
$this->contactHandler = $contactHandler;
}
/**
* @Route("/", name="index", options={"sitemap": true})
*
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*/
public function index(): Response
{
$result = $this->registerHandler->process();
return !is_null($this->getUser())
? $this->redirectToRoute('espace_client_index')
: $this->redirectToRoute('security_login');
}
/**
* @Route("/contact/", name="contact", options={"sitemap": true})
*
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*/
public function contact(): Response
{
$this->contactHandler->process();
return $this->contactHandler->getEmailState() > 0
? $this->redirectToRoute('front_contact')
: $this->render('front/contact.html.twig', [
'form' => $this->contactHandler->getForm()->createView(),
]);
}
/**
* @Route("/mentions-legales/", name="legalnotice", options={"sitemap": true})
*/
public function legalNotice(): Response
{
return $this->render('front/legal-notice.html.twig');
}
/**
* @Route("/tarifs-et-services/", name="servicesprices", options={"sitemap": true})
*/
public function services_prices(): Response
{
return $this->redirect($_ENV['WORDPRESS_WEBSITE_PATH'] . '/nos-tarifs/');
}
/**
* @Route("/services/", name="services", options={"sitemap": true})
*/
public function services(): Response
{
return $this->redirect($_ENV['WORDPRESS_WEBSITE_PATH'] . '/services-fiscaux/');
}
/**
* @Route("/qui-nous-sommes/", name="who_we_are", options={"sitemap": true})
*/
public function whoWeAre(): Response
{
return $this->redirect($_ENV['WORDPRESS_WEBSITE_PATH'] . '/qui-sommes-nous/');
}
/**
* @Route("/retour/vers/pitaxes/", name="back_to_wordpress", options={"sitemap": true})
*/
public function back_to_wordpress(): Response
{
return $this->redirect($_ENV['WORDPRESS_WEBSITE_PATH']);
}
}