- <?php
- namespace App\Controller\Apollon;
- use App\Entity\Apollon\Brick;
- use App\Entity\Apollon\EditorialContent;
- use App\Entity\Apollon\NewsBlog;
- use App\Entity\Apollon\Showcase;
- use App\Entity\Apollon\Website;
- use App\Entity\Apollon\WebsiteInstance;
- use App\Entity\Apollon\WebsitePage;
- use App\Entity\Apollon\WebsiteTemplate;
- use App\Entity\Asclepios\Appointment;
- use App\Entity\Asclepios\Clinic;
- use App\Entity\Asclepios\Order;
- use App\Entity\Athena\User;
- use App\Service\Apollon\AksimetService;
- use App\Service\Apollon\BrickService;
- use App\Service\Apollon\ModulePageService;
- use App\Service\Apollon\MRVVetoService;
- use App\Service\Apollon\ParametersService;
- use App\Service\Apollon\WebsiteTemplateService;
- use App\Service\Asclepios\ClinicService;
- use App\Service\Asclepios\OrderService;
- use App\Service\Athena\DashboardService;
- use App\Service\Apollon\WebsiteService;
- use App\Service\Helios\HeliosService;
- use Random\RandomException;
- use Symfony\Bridge\Twig\Mime\TemplatedEmail;
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- use Symfony\Component\HttpFoundation\BinaryFileResponse;
- use Symfony\Component\HttpFoundation\Cookie;
- use Symfony\Component\HttpFoundation\JsonResponse;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
- use Symfony\Component\Mailer\MailerInterface;
- use Symfony\Component\Mime\Email;
- use Symfony\Component\Routing\Annotation\Route;
- use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
- use Symfony\Component\Security\Core\Security;
- use Doctrine\ORM\EntityManagerInterface;
- use Symfony\Component\HttpFoundation\HeaderUtils;
- use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
- use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
- use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
- use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface as HttpClientTransportExceptionInterface;
- use Symfony\Contracts\HttpClient\HttpClientInterface;
- use Symfony\Contracts\Translation\TranslatorInterface;
- use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
- use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
- class DefaultPublicController extends AbstractController
- {
-     const BANNED_CONTACT_WORDS = [
-         'click here',
-         'download now',
-         'subscribe',
-         'join now',
-         'register',
-         'sign up',
-         'get started',
-         'act now',
-         'don\'t miss out',
-         'apply here',
-         'try now',
-         'learn more',
-         'find out',
-         'check out',
-         'read more',
-         'start now',
-         'visit our website',
-         'use this link',
-         'click this link',
-         'follow this link',
-         'update your info',
-         'claim your offer',
-         'redeem now',
-         'access now',
-         'activate now',
-         'get yours',
-         'shop now',
-         'order now',
-         'buy now',
-         'take action',
-         'see more',
-         'view more',
-         'unveil',
-         'unlock',
-         'reveal',
-         'avail now',
-         'participate now',
-         'enroll now',
-         'reserve now',
-         'save now',
-         'keep up',
-         'catch up',
-         'check in',
-         'log in',
-         'log on',
-         'reach out',
-         'contact us',
-         'email us',
-         'call now',
-         'message us',
-         'life-changing',
-         'once in a lifetime',
-         'unbelievable',
-         'miracle',
-         'revolutionary',
-         'amazing',
-         'incredible',
-         'fantastic',
-         'extraordinary',
-         'never before seen',
-         'jaw-dropping',
-         'groundbreaking',
-         'unprecedented',
-         'mind-blowing',
-         'astounding',
-         'sensational',
-         'staggering',
-         'phenomenal',
-         'marvelous',
-         'breathtaking',
-         'spectacular',
-         'top-notch',
-         'ultimate',
-         'premier',
-         'exclusive',
-         'exceptional',
-         'elite',
-         'superior',
-         'unmatched',
-         'unrivaled',
-         'perfect',
-         'optimal',
-         'best',
-         'greatest',
-         'no. 1',
-         'leading',
-         'foremost',
-         'paramount',
-         'supreme',
-         'transcendent',
-         'magnificent',
-         'majestic',
-         'epic',
-         'legendary',
-         'iconic',
-         'unique',
-         'genuine',
-         'authentic',
-         'certified',
-         'official',
-         'real',
-         'proven',
-         'tested',
-         'trusted',
-         'reliable',
-         'secure',
-         'safe',
-         'effective',
-         'efficient',
-         'powerful',
-         'strong',
-         'potent',
-         'intense',
-         'massive',
-         'huge',
-         'enormous',
-         'giant',
-         'immense',
-         'vast',
-         'expansive',
-         'comprehensive',
-         'extensive',
-         'wide-ranging',
-         'all-encompassing',
-         'complete',
-         'maximum',
-         'absolute',
-         'sheer',
-         'utter',
-         'ultimate',
-         'money',
-         'cash',
-         'profit',
-         'dollar',
-         '$',
-         'income',
-         'earnings',
-         'payday',
-         'salary',
-         'revenue',
-         'returns',
-         'dividend',
-         'capital',
-         'financial freedom',
-         'wealth',
-         'rich',
-         'millionaire',
-         'billionaire',
-         'money-making',
-         'cash back',
-         'cash bonus',
-         'cash advance',
-         'quick cash',
-         'fast cash',
-         'easy money',
-         'extra income',
-         'additional income',
-         'double your income',
-         'triple your income',
-         'make money',
-         'earn cash',
-         'earn money',
-         'passive income',
-         'investment',
-         'invest',
-         'payout',
-         'fund',
-         'funding',
-         'grant',
-         'financial independence',
-         'tax',
-         'deduction',
-         'save money',
-         'saving',
-         'savings',
-         'financial gain',
-         'financial success',
-         'secure your finances',
-         'economic',
-         'economical',
-         'profitable',
-         'profits',
-         'bank',
-         'banking',
-         'bankroll',
-         'fortune',
-         'jackpot',
-         'windfall',
-         'bet',
-         'betting',
-         'wager',
-         'financial windfall',
-         'budget',
-         'budgetary',
-         'low cost',
-         'cost-effective',
-         'price',
-         'priced',
-         'cheap',
-         'cheaper',
-         'cheapest',
-         'discount',
-         'discounted',
-         'offer',
-         'promotion',
-         'sale',
-         'deal',
-         'bargain',
-         'value',
-         'valuable',
-         'inexpensive',
-         'cut-rate',
-         'slash prices',
-         'owner',
-         'quick thought',
-         'your website',
-         'great content',
-         'engaging',
-         'site abandon',
-         'software',
-         'advertising',
-         'ad rejections',
-         'your ads',
-         'flat rate',
-         'scaling',
-         'affiliate',
-         'campaign',
-     ];
-     private BrickService $brickService;
-     private DashboardService $dashboardService;
-     private MRVVetoService $mrvvetoService;
-     private EntityManagerInterface $entityManager;
-     private HeliosService $heliosService;
-     private HttpClientInterface $client;
-     private MailerInterface $mailer;
-     private ModulePageService $modulePageService;
-     private OrderService $orderService;
-     private ParametersService $parameterService;
-     private Security $security;
-     private TranslatorInterface $translator;
-     private WebsiteService $websiteService;
-     private TokenStorageInterface $tokenStorage;
-     private ?User $user;
-     private ?array $address;
-     private string $prefix;
-     private ?string $preview;
-     private int $isAdmin = 0;
-     private ?Request $request;
-     private ?Website $website;
-     private array $message = [];
-     private bool $iframe;
-     private bool $finalPreviewInIframe;
-     private array $args;
-     private string $page;
-     private ClinicService $clinicService;
-     private WebsiteTemplateService $websiteTemplateService;
-     public function __construct(
-         BrickService           $brickService,
-         DashboardService       $dashboardService,
-         MRVVetoService         $mrvvetoService,
-         EntityManagerInterface $entityManager,
-         HeliosService          $heliosService,
-         HttpClientInterface    $client,
-         MailerInterface        $mailer,
-         ModulePageService      $modulePageService,
-         OrderService           $orderService,
-         ParametersService      $parameterService,
-         Security               $security,
-         TranslatorInterface    $translator,
-         WebsiteService         $websiteService,
-         TokenStorageInterface  $tokenStorage,
-         ClinicService          $clinicService,
-         WebsiteTemplateService $websiteTemplateService,
-         private AksimetService $aksimetService
-     )
-     {
-         $this->brickService = $brickService;
-         $this->dashboardService = $dashboardService;
-         $this->mrvvetoService = $mrvvetoService;
-         $this->entityManager = $entityManager;
-         $this->heliosService = $heliosService;
-         $this->client = $client;
-         $this->mailer = $mailer;
-         $this->modulePageService = $modulePageService;
-         $this->orderService = $orderService;
-         $this->parameterService = $parameterService;
-         $this->security = $security;
-         $this->translator = $translator;
-         $this->websiteService = $websiteService;
-         $this->tokenStorage = $tokenStorage;
-         $this->finalPreviewInIframe = false;
-         $this->prefix = '';
-         $this->clinicService = $clinicService;
-         $this->websiteTemplateService = $websiteTemplateService;
-         $this->user = null;
-         $this->address = [];
-     }
-     public function index(Request $request, string $page = ''): Response
-     {
-         $this->request = $request;
-         $this->iframe = isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] === 'iframe';
-         $this->preview = null;
-         if ($this->iframe) {
-             if (count($preview = explode(',', $request->query->get('preview', ''))) == 2) {
-                 $this->preview = $preview[0];
-                 $this->isAdmin = $preview[1];
-             }
-         }
-         $this->args = explode('/', $page);
-         $this->page = array_shift($this->args);
-         $this->website = $this->websiteService->getWebsiteFromDomainName($this->request->getHost());
-         return $this->mainRender();
-     }
-     #[Route('/public/digital/websiteTemplate/{websiteTemplate}/livePreview/{page}', name: 'adminDigitalWebsiteTemplateLivePreview', requirements: ['page' => '.+'])]
-     public function preview(Request $request, WebsiteTemplate $websiteTemplate, $page = ''): Response
-     {
-         $this->request = $request;
-         $this->iframe = isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] === 'iframe';
-         $this->preview = md5(microtime());
-         $this->prefix = '/public/digital/websiteTemplate/' . $websiteTemplate->getId() . '/livePreview';
-         $this->args = explode('/', $page);
-         $this->page = array_shift($this->args);
-         $this->website = new Website();
-         $this->website->setTemplate($websiteTemplate);
-         $this->website->setPreviewToken($this->preview);
-         if ($websiteInstance = $this->entityManager->getRepository(WebsiteInstance::class)->findOneByTemplate($websiteTemplate)) {
-             $this->website->setColorTheme($websiteInstance->getColortheme());
-             $this->website->setPrimaryColor($websiteInstance->getPrimaryColor());
-             $this->website->setSecondaryColor($websiteInstance->getSecondaryColor());
-         }
-         return $this->mainRender();
-     }
-     #[Route('/public/digital/websiteTemplate/{websiteTemplate}/{uuid}/livePreviewWithClinic/{page}', name: 'adminDigitalWebsiteTemplateLivePreviewWithClinic', requirements: ['page' => '.+'])]
-     public function previewWithClinic(Request $request, WebsiteTemplate $websiteTemplate, $uuid, $page = ''): Response
-     {
-         $this->request = $request;
-         $this->iframe = isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] === 'iframe';
-         $this->preview = md5(microtime());
-         $this->prefix = '/public/digital/websiteTemplate/' . $websiteTemplate->getId() . '/' . $uuid . '/livePreviewWithClinic';
-         $this->args = explode('/', $page);
-         $this->page = array_shift($this->args);
-         $this->website = new Website();
-         $this->website->setTemplate($websiteTemplate);
-         $this->website->setPreviewToken($this->preview);
-         if ($websiteInstance = $this->entityManager->getRepository(WebsiteInstance::class)->findOneByTemplate($websiteTemplate)) {
-             $this->website->setColorTheme($websiteInstance->getColortheme());
-             $this->website->setPrimaryColor($websiteInstance->getPrimaryColor());
-             $this->website->setSecondaryColor($websiteInstance->getSecondaryColor());
-         }
-         if ($showcase = $this->entityManager->getRepository(Showcase::class)->findOneByUuid($uuid)) {
-             $this->website->setClinic($showcase->getClinic());
-         }
-         return $this->mainRender();
-     }
-     #[Route('/public/digital/websiteTemplate/{websiteTemplate}/{uuid}/finalPreviewWrapper', name: 'adminDigitalWebsiteTemplateFinalPreviewWrapper')]
-     public function finalPreviewWrapper(WebsiteTemplate $websiteTemplate, $uuid): Response
-     {
-         return $this->render('Apollon/Showcase/finalPreviewWrapper.html.twig', [
-             'url' => $this->generateUrl('adminDigitalWebsiteTemplateFinalPreview', [
-                 'websiteTemplate' => $websiteTemplate->getId(),
-                 'uuid' => $uuid,
-             ],
-                 UrlGeneratorInterface::ABSOLUTE_URL)
-         ]);
-     }
-     #[Route('/public/digital/websiteTemplate/{websiteTemplate}/{uuid}/finalPreview/{page}', name: 'adminDigitalWebsiteTemplateFinalPreview', requirements: ['page' => '.+'])]
-     public function finalPreview(Request $request, WebsiteTemplate $websiteTemplate, $uuid, $page = ''): Response
-     {
-         $this->request = $request;
-         $this->iframe = isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] === 'iframe';
-         $this->finalPreviewInIframe = true;
-         $this->preview = '';
-         $this->prefix = '/public/digital/websiteTemplate/' . $websiteTemplate->getId() . '/' . $uuid . '/finalPreview';
-         $this->args = explode('/', $page);
-         $this->page = array_shift($this->args);
-         $this->website = new Website();
-         $this->website->setTemplate($websiteTemplate);
-         $this->website->setPreviewToken(md5(microtime()));
-         if ($websiteInstance = $this->entityManager->getRepository(WebsiteInstance::class)->findOneByTemplate($websiteTemplate)) {
-             $this->website->setColorTheme($websiteInstance->getColortheme());
-             $this->website->setPrimaryColor($websiteInstance->getPrimaryColor());
-             $this->website->setSecondaryColor($websiteInstance->getSecondaryColor());
-         }
-         if ($showcase = $this->entityManager->getRepository(Showcase::class)->findOneByUuid($uuid)) {
-             $this->website->setClinic($showcase->getClinic());
-         }
-         return $this->mainRender();
-     }
-     public function mainRender(): Response
-     {
-         $this->fillUserInformations();
-         if (
-             ($this->website) &&
-             (
-                 !$this->iframe ||
-                 $this->finalPreviewInIframe ||
-                 (
-                     $this->preview &&
-                     $this->website->getPreviewToken() === $this->preview
-                 )
-             )
-         ) {
-             if ($this->website->getMaintenance() && is_null($this->user)) {
-                 $response = new Response(
-                     $this->renderView('Apollon/maintenance.html.twig', [
-                         'website' => $this->website,
-                         'error' => '',
-                     ]), 503
-                 );
-                 $response->headers->clearCookie('auto_login', '/', $this->request->getHost());
-                 return $response;
-             }
-             try {
-                 $this->request->getSession()->set('maybeNewContactFormToken', bin2hex(random_bytes(32)));
-             } catch (RandomException $e) {
-                 $this->request->getSession()->set('maybeNewContactFormToken', '12345678123456781234567812345678');
-             }
-             $this->message = $this->handleContactForm();
-             $response = match ($this->page) {
-                 '' => $this->homepage(),
-                 'prendre-rendez-vous' => $this->appointment(),
-                 'mon-compte', 'mon-compte-order', 'mon-compte-rdv' => $this->myAccount($this->page),
-                 'mon-compte-password', 'mon-compte-forget', 'mon-compte-creation' => $this->myAccount($this->page, false),
-                 'mentions-legales' => $this->legalNotice(),
-                 'disconnect' => $this->disconnect(),
-                 'getSSOCookie' => $this->getSSOCookie(),
-                 'getCartCookie' => $this->getCartCookie(),
-                 'sitemap' => $this->generateWebSiteSiteMaps(),
-                 'robots.txt' => $this->generateRobotsTxt(),
-                 'condititons-generales' => $this->getGeneralConditionPageLink(),
-                 default => $this->renderPage(),
-             };
-             if ($response->getStatusCode() === 200) {
-                 $this->request->getSession()->set('contactFormToken', $this->request->getSession()->get('maybeNewContactFormToken'));
-             }
-             return $response;
-         }
-         if ($this->request->getHost() === $this->getParameter('pro.domain_name')) {
-             $fetch = ('fetch' === $this->request->headers->get('A-Sending-Method'));
-             try {
-                 $forbidden = $this->renderView($fetch ? 'Athena/errorFetch.html.twig' : 'Athena/error.html.twig', ['url' => $this->getParameter('pro.domain_name')]);
-             } catch (\Exception $e) {
-                 $forbidden = $e->getMessage();
-             }
-             if ($fetch) {
-                 return new JsonResponse(['a-main' => $forbidden], 403);
-             } else {
-                 return new Response($forbidden, 403);
-             }
-         } else {
-             return $this->renderNotFoundPage();
-         }
-     }
-     public function getSSOCookie(): BinaryFileResponse
-     {
-         $response = new BinaryFileResponse(realpath($this->getParameter('kernel.project_dir')) . '/public/olympe/invisible_pixel.png');
-         if (
-             isset($this->args[0]) &&
-             isset($this->args[1]) &&
-             ($user = $this->entityManager->getRepository(User::class)->find($this->args[0])) &&
-             ($user->getTempTokenForSSO() === $this->args[1])
-         ) {
-             $response->headers->setCookie(Cookie::create('auto_login', $user->getEmail() . ':' . bin2hex(md5($this->request->getHost() . $user->getId() . $this->args[1])), time() + 3600 * 24 * 30, '/', $this->request->getHost(), true, true, false, Cookie::SAMESITE_NONE));
-         }
-         return $response;
-     }
-     public function getCartCookie(): BinaryFileResponse
-     {
-         $response = new BinaryFileResponse(realpath($this->getParameter('kernel.project_dir')) . '/public/olympe/invisible_pixel.png');
-         if (isset($this->args[0])) {
-             $response->headers->setCookie(Cookie::create('cart_number_products', $this->args[0], time() + 3600 * 24 * 30, '/', $this->request->getHost(), true, true, false, Cookie::SAMESITE_NONE));
-         }
-         return $response;
-     }
-     private function renderPage(): Response
-     {
-         $header = $this->decodeArgs();
-         foreach ($this->website->getPages() as $websitePage) {
-             if ($websitePage->getPage()?->getCategory()?->getPagePath() === $this->page) {
-                 $addon = [
-                     'websitePage' => $websitePage,
-                     'metaTitle' => $websitePage->getMetaTitle(),
-                     'metaDescription' => $websitePage->getMetaDescription(),
-                     'dark' => $this->website->getTemplate()->getDarkenPrimaryColor(),
-                 ];
-                 return $this->wrappedPage(array_merge(
-                     count($header) > 0 ?
-                         $header :
-                         ['title' => $websitePage->getLabel()],
-                     $addon),
-                     $this->modulePageService->renderModulePage($websitePage, $this->website, $this->args, $this->preview, $this->prefix, $this->message, $this->isAdmin)
-                 );
-             }
-         }
-         return $this->renderNotFoundPage();
-     }
-     private function decodeArgs(): array
-     {
-         $header = [];
-         $decoder = $this->getParameter('arg_decoder');
-         foreach ($this->args as $key => $val) {
-             $datas = explode('-', $val);
-             if (
-                 isset($datas[0]) &&
-                 isset($decoder[$datas[0]]) &&
-                 isset($decoder[$datas[0]]['entity']) &&
-                 $decoder[$datas[0]]['entity'] &&
-                 isset($decoder[$datas[0]]['method']) &&
-                 $decoder[$datas[0]]['method'] &&
-                 isset($datas[1]) &&
-                 is_numeric($datas[1])
-             ) {
-                 if ($value = $this->getDoctrine()->getManager()->getRepository($decoder[$datas[0]]['entity'])?->{$decoder[$datas[0]]['method']}($datas[1])) {
-                     unset($this->args[$key]);
-                     $this->args[$datas[0]] = $value;
-                     if (count($header) === 0) {
-                         $header = $this->websiteService->getHeaderForPublicWrappedPage($value);
-                     }
-                 }
-             }
-         }
-         return $header;
-     }
-     private function handleContactForm(): array
-     {
-         $session = $this->request->getSession();
-         if (
-             isset($_POST['contactFormToken']) &&
-             $_POST['contactFormToken'] == $session->get('contactFormToken') &&
-             $this->website->getClinic() &&
-             $this->website->getClinic()->getEmail()
-         ) {
-             if ($this->testRecaptcha()) {
-                 $content = '';
-                 if (isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['email']) && isset($_POST['message'])) {
-                     $content = $_POST['firstname'] . ' ' . $_POST['lastname'] . ' vous a envoyé un message depuis le formulaire de contact de votre site web.<br/><br/>
-                                 Son email : ' . $_POST['email'] . '<br/><br/>
-                                 Voici son message :<br/>' . $_POST['message'];
-                 } else {
-                     foreach ($_POST as $key => $val) {
-                         if (!in_array($key, ['contactFormToken', 'form-request'])) {
-                             $content .= $key . ' : ' . $val . "\r\n";
-                         }
-                     }
-                 }
-                 $email = (new TemplatedEmail())
-                     ->from('nepasrepondre@clubvet.fr')
-                     ->to($this->website->getClinic()->getEmailContactForm() ?? $this->website->getClinic()->getEmail())
-                     ->subject('Mail reçu du site web' . ($_POST['form-request'] ? ' : ' . $_POST['form-request'] : ''))
-                     ->htmlTemplate('Apollon/Email/genericMail.html.twig')
-                     ->context([
-                         'base_url' => $this->request->getScheme() . '://' . $this->request->getHttpHost() . $this->request->getBasePath(),
-                         'content' => $content,
-                     ]);
-                 try {
-                     $this->mailer->send($email);
-                     return ['status' => 'ok', 'message' => 'Mail envoyé !'];
-                 } catch (TransportExceptionInterface $e) {
-                     return ['status' => 'error', 'message' => $e->getMessage()];
-                 }
-             } else {
-                 return ['status' => 'error', 'message' => 'Vous êtes un robot !'];
-             }
-         }
-         return [];
-     }
-     private function testRecaptcha(): bool
-     {
-         if (isset($_POST['messageSubject']) && $_POST['messageSubject'] != '') {
-             return false;
-         }
-         $message = trim(($_POST['message'] ?? ''));
-         if (empty($message) || $this->containsBannedWord($message)) {
-             return false;
-         }
-         if (
-             ($secret = $this->website->getRecaptchaSecretKey()) &&
-             isset($_POST['g-recaptcha-response']) &&
-             ($captcha = $_POST['g-recaptcha-response'])
-         ) {
-             $file = realpath($this->getParameter('kernel.project_dir')) . '/private/recaptcha_log.txt';
-             file_put_contents($file, date('Y-m-d H:i:s') . ' - ' . $this->website->getDomainName() . ' - ', FILE_APPEND);
-             $response = file_get_contents(
-                 "https://www.google.com/recaptcha/api/siteverify?secret=" . $secret .
-                 "&response=" . $captcha .
-                 "&remoteip=" . $_SERVER['REMOTE_ADDR']
-             );
-             file_put_contents($file, $response . "\r\n", FILE_APPEND);
-             $response = json_decode($response);
-             if ($response->success != true) {
-                 return false;
-             }
-             try {
-                 $spamScore = $this->aksimetService->getSpamScore(
-                     $message,
-                     $this->request->getClientIp() ?? '',
-                     $this->request->headers->get('User-Agent') ?? '',
-                     $_POST['email'] ?? '',
-                     trim(($_POST['firstname'] ?? '') . ' ' . ($_POST['lastname'] ?? '')),
-                     'contact‑form',
-                     new \DateTime('now')
-                 );
-                 if ($spamScore === 2) {
-                     return false;
-                 }
-             } catch (HttpClientTransportExceptionInterface $e) {
-                 // ignore voluntary
-             }
-             return true;
-         }
-         return false;
-     }
-     /**
-      * Check if the message contains banned words
-      * @param string $message The message to check
-      * @return bool True if the message is valid, False if it contains banned words
-      */
-     private function containsBannedWord(string $message): bool
-     {
-         $message = trim($message);
-         if (empty($message)) {
-             return false;
-         }
-         // Protection against XSS attacks
-         $message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
-         $message = mb_strtolower($message);
-         foreach (self::BANNED_CONTACT_WORDS as $bannedWord) {
-             if (empty($bannedWord)) {
-                 continue;
-             }
-             $bannedWord = mb_strtolower(trim($bannedWord));
-             $pattern = '/(?:^|[^\p{L}\p{N}])' . preg_quote($bannedWord, '/') . '(?:[^\p{L}\p{N}]|$)/u';
-             if (preg_match($pattern, $message)) {
-                 return true;
-             }
-         }
-         return false;
-     }
-     /*
-     ## Methods that serve different pages of the public website
-     */
-     private function homepage(): Response
-     {
-         $html = $this->renderView('Apollon/base.html.twig', [
-             'body' => $this->websiteService->renderHTML($this->website, true, $this->message, $this->preview, $this->prefix, $this->isAdmin),
-             'website' => $this->website,
-             'contactFormToken' => $this->request->getSession()->get('contactFormToken'),
-             'preview' => $this->preview,
-             'prefix' => $this->prefix,
-             'websiteTemplateFonts' => $this->websiteTemplateService->getFonts($this->website->getTemplate()),
-         ]);
-         if ($this->request->getSession()->has('askForSSOCookie')) {
-             $this->addCookieImgToHtml($html);
-         }
-         $response = new Response($html, 200);
-         $response->headers->clearCookie('auto_login', '/', $this->request->getHost());
-         return $response;
-     }
-     private function wrappedPage(array $header, string $content, $code = 200): Response
-     {
-         $html = $this->renderView('Apollon/page.html.twig', array_merge($header, [
-             'header' => $this->brickService->renderHeaderHTML($this->website, preview: $this->preview, prefix: $this->prefix, page: $this->page, isAdmin: $this->isAdmin),
-             'content' => $content,
-             'aside' => $this->brickService->renderAsideHTML($this->website, preview: $this->preview, prefix: $this->prefix, page: $this->page, isAdmin: $this->isAdmin),
-             'footer' => $this->brickService->renderFooterHTML($this->website, preview: $this->preview, prefix: $this->prefix, page: $this->page, isAdmin: $this->isAdmin),
-             'website' => $this->website,
-             'preview' => $this->preview,
-             'prefix' => $this->prefix,
-             'websiteTemplateFonts' => $this->website?->getTemplate() ? $this->websiteTemplateService->getFonts($this->website->getTemplate()) : [],
-         ]));
-         if ($this->request->getSession()->has('askForSSOCookie')) {
-             $this->addCookieImgToHtml($html);
-         }
-         $response = new Response($html, $code);
-         $response->headers->clearCookie('auto_login', '/', $this->request->getHost());
-         return $response;
-     }
-     private function addCookieImgToHtml(&$html)
-     {
-         try {
-             $response = $this->client->request(
-                 'GET',
-                 $this->getParameter('prestashop.url') .
-                 '/module/cvs_connect_sso/getSSOToken?customer_email=' .
-                 $this->user?->getEmail()
-             );
-             $html .= '<img src="' .
-                 $this->getParameter('prestashop.url') .
-                 '/module/cvs_connect_sso/getSSOCookie?customer_email=' .
-                 $this->user?->getEmail() .
-                 '&token=' . $response->getContent() . '" alt=""/>';
-         } catch (HttpClientTransportExceptionInterface|ClientExceptionInterface|RedirectionExceptionInterface|ServerExceptionInterface $e) {
-         }
-     }
-     private function appointment(): Response
-     {
-         if (!empty($this->website->getPrimaryColor()))
-             $primaryColor = str_replace("#", "", $this->website->getPrimaryColor());
-         else
-             $primaryColor = str_replace("#", "", $this->website->getColorTheme()?->getPrimaryColor()?->getRgbCode());
-         if (!empty($this->website->getSecondaryColor()))
-             $secondaryColor = str_replace("#", "", $this->website->getSecondaryColor());
-         else
-             $secondaryColor = str_replace("#", "", $this->website->getColorTheme()?->getSecondaryColor()?->getRgbCode());
-         return $this->wrappedPage(
-             ['title' => 'Prendre rendez-vous'],
-             $this->renderView(
-                 'Apollon/RendezVousVeto/monrendezvousveto.html.twig',
-                 [
-                     'environment' => $this->parameterService->getParameter('mon_rendez_vous_veto_environment')->getValue(),
-                     'url' => $this->parameterService->getParameter('mon_rendez_vous_veto_url')->getValue(),
-                     'identifier' => $this->website->getClinic()->getRendezvousvetoId(),
-                     'primaryColor' => $primaryColor,
-                     'secondaryColor' => $secondaryColor,
-                     'rdvEnabled' => $this->website->getClinic()->getClubvetRdv(),
-                     'website' => $this->website,
-                 ]
-             )
-         );
-     }
-     private function myAccount(string $link, bool $userNeeded = true): Response
-     {
-         if ($userNeeded) {
-             if (is_null($this->user)) {
-                 return $this->wrappedPage(
-                     ['title' => 'Mon Compte'],
-                     $this->renderView('Apollon/MonCompte/login.html.twig', [])
-                 );
-             }
-         } else {
-             if (!is_null($this->user)) {
-                 return $this->wrappedPage(
-                     ['title' => 'Mon compte'],
-                     $this->renderView(
-                         'Apollon/MonCompte/myaccount.html.twig',
-                         [
-                             'website' => $this->website,
-                             'user' => $this->user,
-                             'urlShop' => $this->parameterService->getParameter('url_cvs_shop')->getValue(),
-                             'rdvs' => $this->dashboardService->getCustomerRDVs(),
-                             'oldRdvs' => $this->dashboardService->getCustomerRDVs(true),
-                             'orders' => $this->dashboardService->getOrdersInPreparation(),
-                             'oldOrders' => $this->dashboardService->getOrdersInPreparation(true),
-                         ]
-                     )
-                 );
-             }
-         }
-         return match ($link) {
-             'mon-compte' => $this->myAccountindex(),
-             'mon-compte-order' => $this->myAccountOrder(),
-             'mon-compte-rdv' => $this->myAccountAppointment(),
-             'mon-compte-forget' => $this->myAccountForget(),
-             'mon-compte-password' => $this->myAccountPassword(),
-             'mon-compte-creation' => $this->myAccountCreation(),
-         };
-     }
-     private function myAccountIndex(): Response
-     {
-         return $this->wrappedPage(
-             ['title' => 'Mon Compte'],
-             $this->renderView(
-                 'Apollon/MonCompte/myaccount.html.twig',
-                 [
-                     'website' => $this->website,
-                     'user' => $this->user,
-                     'address' => $this->address,
-                     'urlShop' => $this->parameterService->getParameter('url_cvs_shop')?->getValue(),
-                     'rdvs' => $this->dashboardService->getCustomerRDVs(),
-                     'oldRdvs' => $this->dashboardService->getCustomerRDVs(true),
-                     'orders' => $this->dashboardService->getOrdersInPreparation(),
-                     'oldOrders' => $this->dashboardService->getOrdersInPreparation(true),
-                     'error' => $this->request->request->has('maj_user_public') ? $this->majInfoUser() : '',
-                     'user_found' => isset($_POST['search_user']) ?
-                         $this->entityManager->getRepository(User::class)->searchUserPublic($_POST['word_search']) :
-                         null,
-                 ]
-             )
-         );
-     }
-     private function myAccountOrder(): Response
-     {
-         if (
-             $this->request->query->has('id') &&
-             ($order = $this->entityManager->getRepository(Order::class)->find($this->request->query->get('id')))
-         ) {
-             $this->fileName = $order->getReference() . '.pdf';
-             $this->file = $this->orderService->generateInvoicePDF($order);
-             $response = new Response($this->file);
-             $disposition = HeaderUtils::makeDisposition(
-                 HeaderUtils::DISPOSITION_ATTACHMENT,
-                 $this->fileName
-             );
-             $response->headers->set('Content-Disposition', $disposition);
-             return $response;
-         }
-         return new Response();
-     }
-     private function myAccountAppointment(): Response
-     {
-         return $this->wrappedPage(
-             ['title' => 'Mon Compte'],
-             $this->renderView(
-                 'Apollon/MonCompte/myaccount.html.twig',
-                 [
-                     'website' => $this->website,
-                     'user' => $this->user,
-                     'address' => $this->address,
-                     'urlShop' => $this->parameterService->getParameter('url_cvs_shop')?->getValue(),
-                     'rdvs' => $this->dashboardService->getCustomerRDVs(),
-                     'oldRdvs' => $this->dashboardService->getCustomerRDVs(true),
-                     'orders' => $this->dashboardService->getOrdersInPreparation(),
-                     'oldOrders' => $this->dashboardService->getOrdersInPreparation(true),
-                     'errorRdvs' => $this->cancelAppointment(),
-                     'user_found' => null,
-                 ]
-             )
-         );
-     }
-     private function myAccountForget(): Response
-     {
-         $error = '';
-         if ($email = $this->request->request->get('email')) {
-             $baseurl = $this->request->getScheme() . '://' . $this->request->getHttpHost() . $this->request->getBasePath();
-             $user = $this->entityManager->getRepository(User::class)->findOneByEmail($email);
-             if (empty($user)) {
-                 $error = "Aucun compte utilisateur n'existe avec cet e-mail. Veuillez vous inscrire.";
-             } else {
-                 if ($user->getActive()) {
-                     $res = $this->heliosService->updateUser([], $user, true, 'user');
-                     $emailToSend = (new TemplatedEmail())
-                         ->from('nepasrepondre@clubvet.fr')
-                         ->to($email)
-                         ->priority(Email::PRIORITY_HIGH)
-                         ->subject('Réinitialisation de votre mot de passe')
-                         ->htmlTemplate('Apollon/Email/forgottenMDP.html.twig')
-                         ->context([
-                             'base_url' => $baseurl,
-                             'url' => $baseurl . '/mon-compte-password?email=' . $email . '&token=' . $res->getToken()
-                         ]);
-                     try {
-                         $this->mailer->send($emailToSend);
-                         $error = "L'email a été envoyé.";
-                     } catch (TransportExceptionInterface $e) {
-                         $error = "L'e-mail n'a pas été envoyé, veuillez réessayer : " . $baseurl . '/mon-compte-password?email=' . $email . '&token=' . $res->getToken();
-                     }
-                 } else {
-                     $error = "L'utilisateur associé à cet e-mail a été désactivé! Contactez l'administrateur du site.";
-                 }
-             }
-         }
-         return $this->wrappedPage(
-             ['title' => 'Mon Compte'],
-             $this->renderView(
-                 'Apollon/MonCompte/forget.html.twig',
-                 [
-                     'error' => $error,
-                     'email' => $email
-                 ]
-             )
-         );
-     }
-     private function myAccountPassword(): Response
-     {
-         $email = $this->request->query->get('email');
-         $token = $this->request->query->get('token');
-         $error = "";
-         if (empty($email) || empty($token)) {
-             $error = "Vous ne disposez pas des privilèges pour changer de mot de passe!";
-         } else {
-             $pwd = $this->request->request->get('password');
-             $repwd = $this->request->request->get('repassword');
-             if (!empty($pwd) && !empty($repwd)) {
-                 $error = $this->majPassword();
-                 if (empty($error)) {
-                     return $this->wrappedPage(
-                         ['title' => 'Mon Compte'],
-                         $this->renderView('Apollon/MonCompte/login.html.twig', [])
-                     );
-                 }
-             }
-         }
-         return $this->wrappedPage(
-             ['title' => 'Mon Compte'],
-             $this->renderView(
-                 'Apollon/MonCompte/remember.html.twig',
-                 [
-                     'error' => $error,
-                     'email' => $email
-                 ]
-             )
-         );
-     }
-     private function myAccountCreation(): Response
-     {
-         $error = "";
-         $civilite = 1;
-         $firstname = "";
-         $lastname = "";
-         $email = "";
-         $num = "";
-         $adr = "";
-         $cp = "";
-         $city = "";
-         if ($this->request->request->has('create_user_public')) {
-             $civilite = $this->request->request->get('civilite');
-             $firstname = $this->request->request->get('firstname');
-             $lastname = $this->request->request->get('lastname');
-             $email = $this->request->request->get('email');
-             $num = $this->request->request->get('numero');
-             $adr = $this->request->request->get('adr');
-             $cp = $this->request->request->get('cp');
-             $city = $this->request->request->get('city');
-             $error = $this->createUser();
-             if (empty($error)) {
-                 return $this->wrappedPage(
-                     ['title' => 'Mon Compte'],
-                     $this->renderView('Apollon/MonCompte/login.html.twig', [
-                         'success' => 'Votre compte a bien été créé!'
-                     ])
-                 );
-             }
-         }
-         return $this->wrappedPage(
-             ['title' => 'Mon Compte'],
-             $this->renderView(
-                 'Apollon/MonCompte/createuser.html.twig',
-                 [
-                     'error' => $error,
-                     'civilite' => $civilite,
-                     'firstname' => $firstname,
-                     'lastname' => $lastname,
-                     'email' => $email,
-                     'num' => $num,
-                     'adr' => $adr,
-                     'cp' => $cp,
-                     'city' => $city
-                 ]
-             )
-         );
-     }
-     private function cancelAppointment(): string
-     {
-         if (!$this->request->query->has('event_id')) {
-             return 'Pas d\'identifiant passé en paramètre';
-         }
-         $id = $this->request->query->get('event_id');
-         if (is_null($appointment = $this->entityManager->getRepository(Appointment::class)->findOneByEventId($id))) {
-             return "Ce rendez-vous n'existe pas!";
-         }
-         if ($appointment->getClubvetCustomerId() != $this->user->getId()) {
-             return "Ce rendez-vous ne vous appartient pas!";
-         }
-         return $this->mrvvetoService->cancelAppointment(
-             $appointment,
-             $this->website->getClinic(),
-             $id,
-             $this->request,
-             $this->user,
-             $this->mailer
-         );
-     }
-     private function majInfoUser()
-     {
-         $firstname = $this->request->request->get('firstname');
-         $lastname = $this->request->request->get('lastname');
-         $email = $this->request->request->get('email');
-         $num = $this->request->request->get('numero');
-         $adr = $this->request->request->get('adr');
-         $cp = $this->request->request->get('cp');
-         $city = $this->request->request->get('city');
-         if (!$this->isName($firstname)) {
-             return 'Votre prénom est invalide';
-         }
-         if (!$this->isName($lastname)) {
-             return 'Votre nom est invalide';
-         }
-         $userRepository = $this->entityManager->getRepository(User::class);
-         if ($this->user->getEmail() == $email)
-             $newUser = NULL;
-         else
-             $newUser = $userRepository->findOneByEmail($email);
-         if ($newUser === NULL) {
-             $customer['lastname'] = $lastname;
-             $customer['firstname'] = $firstname;
-             $customer['email'] = $email;
-             $customer['other']['id_gender'] = $this->user->getOther()['id_gender'];
-             $customer['other']['veterinaire'] = $this->website->getClinic()->getPrestashopId();
-             $customer['other']['address'][0]['alias'] = 'Mon adresse';
-             $customer['other']['address'][0]['company'] = '';
-             $customer['other']['address'][0]['lastname'] = $lastname;
-             $customer['other']['address'][0]['firstname'] = $firstname;
-             $customer['other']['address'][0]['id_country'] = 8;
-             $customer['other']['address'][0]['id_state'] = 0;
-             $customer['other']['address'][0]['address1'] = $adr;
-             $customer['other']['address'][0]['address2'] = "";
-             $customer['other']['address'][0]['postcode'] = $cp;
-             $customer['other']['address'][0]['city'] = $city;
-             $customer['other']['address'][0]['other'] = "";
-             $customer['other']['address'][0]['phone'] = "";
-             $customer['other']['address'][0]['phone_mobile'] = $num;
-             $this->heliosService->tracker(
-                 'Front site public',
-                 'Clubvet Pro -> SSO',
-                 $this->translator->trans(
-                     'helios.controller.helios.msg_modification_user_public',
-                     ['email' => $email],
-                     'Helios'
-                 )
-             );
-             $res = $this->heliosService->updateUser($customer, $this->user, true, 'user');
-             if ($res->getId() !== NULL) {
-                 $this->user = $res;
-                 if (array_key_exists('address', $this->user->getOther()))
-                     $this->address = $this->user->getOther()['address'][0];
-                 $this->heliosService->dispatcherUserRequest(
-                     $res,
-                     'user_info'
-                 );
-                 return "";
-             } else {
-                 return "L'utilisateur n'a pas été modifié.";
-             }
-         } else {
-             return "Un compte utilisateur existe avec la nouvelle adresse email.";
-         }
-     }
-     private function majPassword()
-     {
-         $email = $this->request->query->get('email');
-         $token = $this->request->query->get('token');
-         $pwd = $this->request->request->get('password');
-         $repwd = $this->request->request->get('repassword');
-         if ($pwd === $repwd) {
-             $userRepository = $this->entityManager->getRepository(User::class);
-             $user = $userRepository->findOneByEmail($email);
-             if (empty($user)) {
-                 return "Aucun compte utilisateur n'existe avec cet e-mail. Veuillez vous inscrire.";
-             } else {
-                 if ($user->getActive()) {
-                     if ($user->getToken() == $token) {
-                         $data['password'] = $pwd;
-                         $res = $this->heliosService->updateUser($data, $user, true, 'user');
-                         if ($res->getId() !== NULL) {
-                             $this->heliosService->dispatcherUserRequest(
-                                 $res,
-                                 'user_info',
-                                 $data['password']
-                             );
-                             return "";
-                         } else {
-                             return "Le mot de passe n'a pas été modifié.";
-                         }
-                     } else {
-                         return "Votre token n'est plus valide ou n'existe pas!";
-                     }
-                 } else {
-                     return "L'utilisateur associé à cet e-mail a été désactivé! Contactez l'administrateur du site.";
-                 }
-             }
-         } else {
-             return "Les mots de passe ne sont pas identiques!";
-         }
-     }
-     private function createUser()
-     {
-         $civilite = $this->request->request->get('civilite');
-         $firstname = $this->request->request->get('firstname');
-         $lastname = $this->request->request->get('lastname');
-         $password = $this->request->request->get('password');
-         $repassword = $this->request->request->get('repassword');
-         $email = $this->request->request->get('email');
-         $num = $this->request->request->get('numero');
-         $adr = $this->request->request->get('adr');
-         $cp = $this->request->request->get('cp');
-         $city = $this->request->request->get('city');
-         if (!$this->isName($firstname)) {
-             return 'Votre prénom est invalide';
-         }
-         if (!$this->isName($lastname)) {
-             return 'Votre nom est invalide';
-         }
-         $userRepository = $this->entityManager->getRepository(User::class);
-         $user = $userRepository->findOneByEmail($email);
-         if ($user === NULL) {
-             if ($password === $repassword) {
-                 $customer['lastname'] = $lastname;
-                 $customer['firstname'] = $firstname;
-                 $customer['email'] = $email;
-                 $customer['password'] = $password;
-                 $customer['other']['id_gender'] = $civilite;
-                 $customer['other']['veterinaire'] = $this->website->getClinic()->getPrestashopId();
-                 $customer['other']['address'][0]['alias'] = 'Mon adresse';
-                 $customer['other']['address'][0]['company'] = '';
-                 $customer['other']['address'][0]['lastname'] = $lastname;
-                 $customer['other']['address'][0]['firstname'] = $firstname;
-                 $customer['other']['address'][0]['id_country'] = 8;
-                 $customer['other']['address'][0]['id_state'] = 0;
-                 $customer['other']['address'][0]['address1'] = $adr;
-                 $customer['other']['address'][0]['address2'] = "";
-                 $customer['other']['address'][0]['postcode'] = $cp;
-                 $customer['other']['address'][0]['city'] = $city;
-                 $customer['other']['address'][0]['other'] = "";
-                 $customer['other']['address'][0]['phone'] = "";
-                 $customer['other']['address'][0]['phone_mobile'] = $num;
-                 $this->heliosService->tracker(
-                     'Front site public',
-                     'Clubvet Pro -> SSO',
-                     $this->translator->trans(
-                         'helios.controller.helios.msg_creation_user_front_public',
-                         ['email' => $email],
-                         'Helios'
-                     )
-                 );
-                 $res = $this->heliosService->createUser($customer);
-                 if ($res->getId() !== NULL) {
-                     $this->heliosService->dispatcherUserRequest(
-                         $res,
-                         'user_info',
-                         $customer['password']
-                     );
-                     return "";
-                 } else {
-                     return "L'utilisateur n'a pas été créé.";
-                 }
-             } else {
-                 return "Les mots de passe ne sont pas identiques.";
-             }
-         } else {
-             return "Un compte utilisateur existe avec cet e-mail. Veuillez faire un rappel de mot de passe si vous l'avez oublié.";
-         }
-     }
-     private function disconnect()
-     {
-         $token = new AnonymousToken('default', 'anon.');
-         $this->tokenStorage->setToken($token);
-         $this->request->getSession()->invalidate();
-         return $this->wrappedPage(
-             ['title' => 'Mon Compte'],
-             $this->renderView('Apollon/MonCompte/login.html.twig', [])
-         );
-     }
-     public function isName($name): bool
-     {
-         return preg_match($this->cleanNonUnicodeSupport('/^[^0-9!<>,;?=+()@#"°{}_$%:]*$/u'), stripslashes($name));
-     }
-     public function cleanNonUnicodeSupport($pattern): string
-     {
-         return preg_replace('/\\\[px]\{[a-z]{1,2}\}|(\/[a-z]*)u([a-z]*)$/i', '$1$2', $pattern);
-     }
-     private function legalNotice(): Response
-     {
-         $legalRepresentatives = [];
-         if ($this->website->getClinic()) {
-             foreach ($this->website->getClinic()->getClinicEmployeeClinics() as $employee) {
-                 if ($employee->getOwner()) {
-                     $legalRepresentatives[] = $employee->getClinicEmployee()?->getFirstname() . ' ' . strtoupper($employee->getClinicEmployee()?->getLastname());
-                 }
-             }
-         }
-         return $this->wrappedPage(
-             ['title' => 'Mentions légales et données personnelles'],
-             $this->renderView('Apollon/LegalNotice/legalNotice.html.twig', [
-                 'clinic_sign' => $this->website->getClinic()?->getSign() ?? 'Sans nom',
-                 'clinic_address' => $this->website->getClinic()?->getAddress() ?? '---',
-                 'clinic_postal_code' => $this->website->getClinic()?->getPostalCode() ?? '---',
-                 'clinic_city' => $this->website->getClinic()?->getCity() ?? '---',
-                 'clinic_type' => strtolower($this->website->getClinic()?->getType()?->getLabel() ?? 'Clinique'),
-                 'clinic_kind' => $this->website->getClinic()?->getType()?->getKind() ?? 'f',
-                 'clinic_owners' => implode(', ', $legalRepresentatives),
-                 'clinic_url' => $this->website->getUrl(),
-                 'clinic_domain_name' => $this->website->getDomainName(),
-                 'clinic_recaptcha' => $this->website->getRecaptchaSecretKey(),
-                 'clinic_ga' => $this->website->getGoogleAnalyticsKey(),
-             ])
-         );
-     }
-     private function renderNotFoundPage(): Response
-     {
-         return $this->wrappedPage(
-             ['title' => 'Vous êtes perdu•e ?'],
-             $this->renderView('Apollon/notFound.html.twig'),
-             404
-         );
-     }
-     public function generateWebSiteSiteMaps(): Response
-     {
-         $results = [];
-         $clinicPages = $this->clinicService->getClinicPages($this->website->getClinic(), 1000);
-         $clinicTipSheets = $this->clinicService->getClinicTipSheets($this->website->getClinic(), 1000);
-         $pages = $this->getDoctrine()->getRepository(WebsitePage::class)->findByWebsiteTemplate($this->website->getTemplate(), ['weight' => 'ASC']);
-         foreach ($pages as $page) {
-             $results[] = ['websitePage' => $page, 'subLinks' => $this->websiteService->getSubLinks($page, $this->website->getClinic())];
-         }
-         $xml = '<?xml version="1.0" encoding="UTF-8"?>';
-         $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
-         $xml .= '<url>';
-         $xml .= '<loc>https://' . $this->website->getDomainName() . '</loc>';
-         $xml .= '<lastmod>' . date('Y-m-d') . '</lastmod>';
-         $xml .= '</url>';
-         foreach ($results as $result) {
-             $xml .= '<url>';
-             $xml .= '<loc>https://' . $this->website->getDomainName() . '/' . $result['websitePage']->getPage()->getCategory()->getPagePath() . '</loc>';
-             $xml .= '<lastmod>' . date('Y-m-d') . '</lastmod>';
-             $xml .= '</url>';
-         }
-         if ($this->displayNewsOnSitmap()) {
-             $clinicBlogs = $this->clinicService->getClinicNewsBlog($this->website->getClinic(), 1000);
-             if ($clinicBlogs) {
-                 if ($clinicBlogs['news']) {
-                     foreach ($clinicBlogs['news'] as $newsBlog) {
-                         $xml .= '<url>';
-                         $xml .= '<loc>https://' . $this->website->getDomainName() . '/actualites/article-' . $newsBlog->getId() . '-' . $newsBlog->getSlug() . '</loc>';
-                         $xml .= '<lastmod>' . date('Y-m-d') . '</lastmod>';
-                         $xml .= '</url>';
-                     }
-                 }
-             }
-         }
-         if ($clinicTipSheets) {
-             if ($clinicTipSheets['sheets']) {
-                 foreach ($clinicTipSheets['sheets'] as $clinicTipSheet) {
-                     $xml .= '<url>';
-                     $xml .= '<loc>https://' . $this->website->getDomainName() . '/fiches-conseil/fiche-' . $clinicTipSheet->getId() . '-' . $clinicTipSheet->getSlug() . '</loc>';
-                     $xml .= '<lastmod>' . date('Y-m-d') . '</lastmod>';
-                     $xml .= '</url>';
-                 }
-             }
-         }
-         if ($clinicPages) {
-             foreach ($clinicPages as $clinicPage) {
-                 $xml .= '<url>';
-                 $xml .= '<loc>https://' . $this->website->getDomainName() . '/pages/page-' . $clinicPage->getId() . '-' . $clinicPage->getSlug() . '</loc>';
-                 $xml .= '<lastmod>' . date('Y-m-d') . '</lastmod>';
-                 $xml .= '</url>';
-             }
-         }
-         $xml .= '</urlset>';
-         $response = new Response($xml);
-         $response->headers->set('Content-Type', 'xml');
-         return $response;
-     }
-     public function generateRobotsTxt(): Response
-     {
-         return new Response("User-agent: *\r\nAllow: /\r\n\r\nSitemap: https://{$this->website->getDomainName()}/sitemap");
-     }
-     private function getGeneralConditionPageLink(): Response
-     {
-         $legalRepresentatives = [];
-         if ($this->website->getClinic()) {
-             foreach ($this->website->getClinic()->getClinicEmployeeClinics() as $employee) {
-                 if ($employee->getOwner()) {
-                     $legalRepresentatives[] = $employee->getClinicEmployee()?->getFirstname() . ' ' . strtoupper($employee->getClinicEmployee()?->getLastname());
-                 }
-             }
-         }
-         $editorialContent = $this->entityManager->getRepository(EditorialContent::class)
-             ->findOneBy(
-                 [
-                     'isGeneralConditionPage' => true,
-                     'clinic' => $this->website->getClinic()
-                 ]
-             );
-         return $this->wrappedPage(
-             ['title' => 'Conditions générales'],
-             $this->renderView('Apollon/GeneralCondition/generalCondition.twig', [
-                 'clinic_sign' => $this->website->getClinic()?->getSign() ?? 'Sans nom',
-                 'clinic_address' => $this->website->getClinic()?->getAddress() ?? '---',
-                 'clinic_postal_code' => $this->website->getClinic()?->getPostalCode() ?? '---',
-                 'clinic_city' => $this->website->getClinic()?->getCity() ?? '---',
-                 'clinic_type' => strtolower($this->website->getClinic()?->getType()?->getLabel() ?? 'Clinique'),
-                 'clinic_kind' => $this->website->getClinic()?->getType()?->getKind() ?? 'f',
-                 'clinic_owners' => implode(', ', $legalRepresentatives),
-                 'clinic_url' => $this->website->getUrl(),
-                 'clinic_domain_name' => $this->website->getDomainName(),
-                 'clinic_recaptcha' => $this->website->getRecaptchaSecretKey(),
-                 'clinic_ga' => $this->website->getGoogleAnalyticsKey(),
-                 'page' => $editorialContent
-             ])
-         );/*
-         if ($this->website->getClinic() && $editorialContent = $this->entityManager->getRepository(EditorialContent::class)->findOneBy(['isGeneralConditionPage'=>true, 'clinic'=>$this->website->getClinic()])) {
-             $website = $this->entityManager->getRepository(Website::class)->findOneBy(['clinic'=>$this->website->getClinic()->getId()]);
-             return $website ? $website->getUrl().$editorialContent->getUrl(): '';
-         }
-         return '';*/
-     }
-     public function displayNewsOnSitmap()
-     {
-         if ($template = $this->website->getTemplate()) {
-             if (
-                 $template->getMain() &&
-                 ($module = $this->getDoctrine()->getRepository(Brick::class)->find($template->getMain()->getId()))
-             ) {
-                 foreach ($module->getBricks() as $brick) {
-                     if ($brick->getModule()?->getCategory()->getPagePath() == 'actualites') {
-                         return true;
-                     }
-                 }
-             }
-             foreach ($template->getPages() as $page) {
-                 if ($page->getPage()->getCategory()->getPagePath() == 'actualites') {
-                     return true;
-                 }
-             }
-         }
-         return false;
-     }
-     private function fillUserInformations(): void
-     {
-         if (is_null($this->user)) {
-             $this->user = $this->security->getUser();
-             $this->address =
-                 (
-                     $this->user &&
-                     !empty($this->user->getOther())
-                     && array_key_exists('address', $this->user->getOther())
-                 ) ?
-                     $this->user->getOther()['address'][0] :
-                     [];
-         }
-     }
- }
-