src/Controller/Client/AbstractClientController.php line 122

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Client;
  3. use App\Entity\Contact;
  4. use App\Entity\ContactCreationSociete;
  5. use App\Entity\ContactInvestissementImmo;
  6. use App\Entity\ContactInvestissementImmoProperty;
  7. use App\Entity\ContactInvestissementImmoPropertyCharge;
  8. use App\Entity\EmailBlacklist;
  9. use App\Form\ContactCreationSocieteType;
  10. use App\Form\ContactInvestissementImmoType;
  11. use App\Services\MoneticoService;
  12. use App\Services\QueriesV2Manager;
  13. use Psr\Log\LoggerInterface;
  14. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  15. use Twig\Environment;
  16. use App\Form\ContactType;
  17. use App\Services\WebSite;
  18. use App\Form\MiniBookType;
  19. use App\Entity\ApplyRequest;
  20. use App\Form\NewsletterType;
  21. use App\Entity\AccountingFirm;
  22. use App\Form\EbookDownloadType;
  23. use App\Form\CompanyCreationType;
  24. use App\Form\AnnouncementApplyType;
  25. use App\Repository\AliasRepository;
  26. use App\Services\SendContactEmail as CE;
  27. use App\Repository\AccountingFirmRepository;
  28. use Symfony\Component\HttpFoundation\Request;
  29. use Symfony\Component\Mailer\MailerInterface;
  30. use Symfony\Component\HttpFoundation\Response;
  31. use App\Controller\Client\ClientWidgetController;
  32. use App\Entity\ContactProfession;
  33. use App\Form\ContactProfessionType;
  34. use App\Form\ContactCustomType;
  35. use App\Form\ContactEtreRappeleType;
  36. use App\Repository\DynDataRepository;
  37. use App\Repository\AnnouncementRepository;
  38. use Symfony\Component\HttpFoundation\RequestStack;
  39. use Symfony\Component\HttpFoundation\RedirectResponse;
  40. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  41. use App\Services\AccountingFirmResolver;
  42. use Symfony\Contracts\Cache\CacheInterface;
  43. abstract class AbstractClientController extends AbstractController
  44. {
  45.     protected $accountingFirm;
  46.     protected $templateBase;
  47.     protected $mailer;
  48.     protected $request;
  49.     protected $redirect;
  50.     protected $formview;
  51.     protected $formsend;
  52.     protected $formlivreview;
  53.     protected $form_send_livre;
  54.     protected $formcompanyview;
  55.     protected $form_send_company;
  56.     protected $formprofessionview;
  57.     protected $formetrerappeleview;
  58.     protected $form_send_profession;
  59.     protected $form_send_etreRappele;
  60.     protected $formnewsletterview;
  61.     protected $form_send_newsletter;
  62.     protected $formminibookview;
  63.     protected $form_send_minibook;
  64.     protected $formrecrutementview;
  65.     protected $form_send_recrutement;
  66.     protected $formprevicreationview;
  67.     protected $form_send_previ_creation;
  68.     protected $formpreviimmoview;
  69.     protected $form_send_previ_immo;
  70.     protected $formcustomview;
  71.     protected $form_send_custom;
  72.     protected $CE;
  73.     protected $twig;
  74.     protected $site;
  75.     protected $dynData;
  76.     protected $dynDataArray;
  77.     protected $dynDataText;
  78.     protected $announcementMain;
  79.     protected $announcementSpontanee;
  80.     protected $serviceQMV2;
  81.     protected  $moneticoService;
  82.     protected $theHost;
  83.     protected $logger;
  84.     protected $cache;
  85.     public function __construct(RequestStack $requestAccountingFirmRepository $accountingFirmRepositoryAliasRepository $aliasrepositoryMailerInterface $mailerCE $CEEnvironment $twigWebSite $siteAnnouncementRepository $announcementRepositoryDynDataRepository $dynDataRepositoryQueriesV2Manager $serviceQMV2MoneticoService $moneticoServiceLoggerInterface $loggerAccountingFirmResolver $accountingFirmResolverCacheInterface $cache)
  86.     {
  87.         $this->moneticoService $moneticoService;
  88.         $this->logger $logger;
  89.         $this->cache $cache;
  90.         $theHost $request->getCurrentRequest()->getHost();
  91.         $theHost str_replace('www.'''$theHost);
  92.         if (preg_match('/preview/'$request->getCurrentRequest()->get('_route'))) {
  93.             $theHost $request->getCurrentRequest()->attributes->get('host');
  94.         }
  95.         // $theHost = 'cabinet-za.de';
  96.         // ✅ UTILISATION DU RESOLVER CENTRALISÉ - évite la duplication avec le Voter
  97.         $this->accountingFirm $accountingFirmResolver->resolve();
  98.         // Gestion de la redirection si alias ou host non trouvé
  99.         if (is_null($this->accountingFirm)) {
  100.             $alias $aliasrepository->findOneBy([
  101.                 'name' => $theHost
  102.             ]);
  103.             if (!is_null($alias)) {
  104.                 $acID $alias->getParameter()->getAccountingFirm()->getId();
  105.                 $this->accountingFirm $accountingFirmRepository->findOneBy([
  106.                     'id' => $acID
  107.                 ]);
  108.                 $this->redirect $this->accountingFirm->getHost();
  109.             } else {
  110.                 $this->redirect 404;
  111.             }
  112.         }
  113.         $theHost $this->accountingFirm->getHost();
  114.         $this->theHost $theHost;
  115.         // ✅ OPTIMISATION : Cache des DynData avec relations hydratées
  116.         // On récupère directement depuis le repository (pas de cache d'entités Doctrine)
  117.         // car les relations lazy-loaded ne survivent pas à la sérialisation du cache
  118.         $this->dynData $dynDataRepository->findAll();
  119.         // Filtrer par type - on garde les entités complètes avec relations hydratées
  120.         $this->dynDataArray array_values(array_filter($this->dynData, fn($d) => $d->getType() === 'ARRAY'));
  121.         $this->dynDataText array_values(array_filter($this->dynData, fn($d) => $d->getType() === 'TEXT'));
  122.         if (!empty($this->accountingFirm)) {
  123.             $this->announcementMain $announcementRepository->findMyAnnouncementMain($this->accountingFirm);
  124.             $this->announcementSpontanee $announcementRepository->findMyAnnouncementsSpontanee($this->accountingFirm);
  125.         }
  126.         $this->templateBase '/' $theHost '/templates/';
  127.         $this->request $request;
  128.         $this->mailer $mailer;
  129.         $this->formsend false;
  130.         $this->form_send_livre false;
  131.         $this->form_send_company false;
  132.         $this->form_send_newsletter false;
  133.         $this->form_send_minibook false;
  134.         $this->form_send_recrutement false;
  135.         $this->form_send_custom false;
  136.         $this->form_send_previ_creation false;
  137.         $this->form_send_previ_immo false;
  138.         $this->CE $CE;
  139.         $this->twig $twig;
  140.         $this->site $site;
  141.         $this->serviceQMV2 $serviceQMV2;
  142.     }
  143.     protected function render(string $view, array $parameters = [], Response $response null, array $return = []): Response
  144.     {
  145.         // ✅ OPTIMISATION : Cache du fichier entrypoints.json (évite I/O disque + parsing JSON)
  146.         // Le cache sera automatiquement invalidé au prochain déploiement
  147.         $build $this->cache->get('build_entrypoints', function() {
  148.             $filePath $this->getParameter('kernel.project_dir') . '/public/build/entrypoints.json';
  149.             return json_decode(file_get_contents($filePath), true);
  150.         });
  151.         $this->twig->addGlobal('build'$build);
  152.         $this->twig->addGlobal('serverActuUrl'$this->site->getServerActuUrl());
  153.         // set redirection
  154.         if (!is_null($this->redirect)) {
  155.             if ($this->redirect == 404) {
  156.                 return new Response(""404);
  157.                 die();
  158.             } else {
  159.                 $this->redirect "https://" $this->redirect;
  160.             }
  161.         }
  162.         // Access from actualite-du-mois.php
  163.         if ($this->request && $this->request->getCurrentRequest() && $this->request->getCurrentRequest()->getBaseUrl() == "/actualite-du-mois.php") {
  164.             if ($this->redirectRouteV2($this->request->getCurrentRequest())) {
  165.                 $redirect $this->redirectRouteV2($this->request->getCurrentRequest());
  166.                 $redirect str_replace("actualite-du-mois.php"""$redirect);
  167.                 $redirect str_replace("//""/"$redirect);
  168.             } else {
  169.                 $redirect "/actualite-du-mois";
  170.             }
  171.             if (empty($this->redirect)) {
  172.                 $this->redirect "https://" $this->request->getCurrentRequest()->getHttpHost() . $redirect;
  173.             } else {
  174.                 $this->redirect $this->redirect $redirect;
  175.             }
  176.         }
  177.         // do redirection
  178.         if (!is_null($this->redirect)) {
  179.             return new RedirectResponse($this->redirect);
  180.             die();
  181.         }
  182.         // SETUP
  183.         $entityManager $this->getDoctrine()->getManager();
  184.         // Contact
  185.         $form $this->createForm(ContactType::class, null, ['cabinet' => $this->accountingFirm]);
  186.         $request $this->get('request_stack')->getCurrentRequest();
  187.         $form->get('form_timestamp')->setData(time());
  188.         $form->get('route')->setData($request->attributes->get('_route'));
  189.         if ($request->attributes->get('_route') == 'previewprescripteur_client' || $request->attributes->get('_route') == 'prescripteur_client') {
  190.             $form->get('id_prescriber')->setData($request->attributes->get('id'));
  191.         }
  192.         $form->handleRequest($request);
  193.         $this->formview $form->createView();
  194.         if ($form->isSubmitted() && $form->isValid()) {
  195.             $name $form->get('name')->getData();
  196.             $email $form->get('email')->getData();
  197.             $message $form->get('message')->getData();
  198.             $fiveMinutesAgo = new \DateTime('-5 minutes');
  199.             $existingContact $this->getDoctrine()->getRepository(Contact::class)->findRecentContactByName($name$fiveMinutesAgo);
  200.             $submittedAt = (int) $form->get('form_timestamp')->getData();
  201.             $now time();
  202.             $elapsedSeconds $now $submittedAt;
  203.             // Anti-spam : formulaire soumis trop vite
  204.             if ($elapsedSeconds 3) {
  205.                 // Ajout à la blacklist
  206.                 $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  207.                 $entityManager $this->getDoctrine()->getManager();
  208.                 $blacklistedEmail $blacklistRepo->findByEmail($email);
  209.                 if (!$blacklistedEmail) {
  210.                     $blacklistedEmail = new EmailBlacklist();
  211.                     $blacklistedEmail->setEmail($email);
  212.                     $blacklistedEmail->setName($name);
  213.                     $blacklistedEmail->setBlockCount(1);
  214.                 } else {
  215.                     $blacklistedEmail->incrementBlockCount();
  216.                 }
  217.                 $entityManager->persist($blacklistedEmail);
  218.                 $entityManager->flush();
  219.             }
  220.             // Détection message spam type "ClbNCSjWDTZMonBownuySkg"
  221.             if ($this->isGibberishMessage($message)) {
  222.                 $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  223.                 $entityManager $this->getDoctrine()->getManager();
  224.                 $blacklistedEmail $blacklistRepo->findByEmail($email);
  225.                 if (!$blacklistedEmail) {
  226.                     $blacklistedEmail = new EmailBlacklist();
  227.                     $blacklistedEmail->setEmail($email);
  228.                     $blacklistedEmail->setName($name);
  229.                     $blacklistedEmail->setBlockCount(1);
  230.                 } else {
  231.                     $blacklistedEmail->incrementBlockCount();
  232.                 }
  233.                 $entityManager->persist($blacklistedEmail);
  234.                 $entityManager->flush();
  235.             }
  236.             // Vérifier si l'email est dans la blacklist
  237.             $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  238.             if (!($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) && !$existingContact && stripos($message"free") === false) {
  239.                 $this->CE->sendContactEmail($form);
  240.             } elseif ($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) {
  241.                 // Incrémenter le compteur de tentatives
  242.                 $blacklistedEmail $blacklistRepo->findByEmail($email);
  243.                 if ($blacklistedEmail) {
  244.                     $blacklistedEmail->incrementBlockCount();
  245.                     $entityManager $this->getDoctrine()->getManager();
  246.                     $entityManager->persist($blacklistedEmail);
  247.                     $entityManager->flush();
  248.                 }
  249.             }
  250.             $this->formsend true;
  251.         }
  252.         // Contact Custom
  253.         $form_custom $this->createForm(ContactCustomType::class, null, ['cabinet' => $this->accountingFirm]);
  254.         $form_custom->handleRequest($request);
  255.         $this->formcustomview $form_custom->createView();
  256.         if ($form_custom->isSubmitted() && $form_custom->isValid()) {
  257.             $name $form_custom->get('name')->getData();
  258.             $email $form_custom->get('email')->getData();
  259.             $message $form_custom->get('message')->getData();
  260.             // Vérifier si l'email est dans la blacklist
  261.             $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  262.             if (!($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) && stripos($message"free") === false) {
  263.                 $this->CE->sendContactCustomEmail($form_custom);
  264.             } elseif ($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) {
  265.                 // Incrémenter le compteur de tentatives
  266.                 $blacklistedEmail $blacklistRepo->findByEmail($email);
  267.                 if ($blacklistedEmail) {
  268.                     $blacklistedEmail->incrementBlockCount();
  269.                     $entityManager $this->getDoctrine()->getManager();
  270.                     $entityManager->persist($blacklistedEmail);
  271.                     $entityManager->flush();
  272.                 }
  273.             }
  274.             $this->form_send_custom true;
  275.         }
  276.         // EbookDownload
  277.         $form_livre $this->createForm(EbookDownloadType::class);
  278.         $form_livre->handleRequest($request);
  279.         $this->formlivreview $form_livre->createView();
  280.         if ($form_livre->isSubmitted() && $form_livre->isValid()) {
  281.             $this->CE->sendEbookEmail($form_livre);
  282.             $this->form_send_livre true;
  283.         }
  284.         // company
  285.         $form_company $this->createForm(CompanyCreationType::class, null, ['cabinet' => $this->accountingFirm]);
  286.         $form_company->handleRequest($request);
  287.         $this->formcompanyview $form_company->createView();
  288.         if ($form_company->isSubmitted() && $form_company->isValid()) {
  289.             $name $form_company->get('name')->getData();
  290.             $email $form_company->get('email')->getData();
  291.             // Vérifier si l'email est dans la blacklist
  292.             $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  293.             if (!($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name))) {
  294.                 $this->CE->sendCompanyEmail($form_company);
  295.             } elseif ($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) {
  296.                 // Incrémenter le compteur de tentatives
  297.                 $blacklistedEmail $blacklistRepo->findByEmail($email);
  298.                 if ($blacklistedEmail) {
  299.                     $blacklistedEmail->incrementBlockCount();
  300.                     $entityManager $this->getDoctrine()->getManager();
  301.                     $entityManager->persist($blacklistedEmail);
  302.                     $entityManager->flush();
  303.                 }
  304.             }
  305.             $this->form_send_company true;
  306.         }
  307.         // company
  308.         $form_profession $this->createForm(ContactProfessionType::class, null, ['cabinet' => $this->accountingFirm]);
  309.         $form_profession->handleRequest($request);
  310.         $this->formprofessionview $form_profession->createView();
  311.         if ($form_profession->isSubmitted() && $form_profession->isValid()) {
  312.             $name $form_profession->get('name')->getData();
  313.             $email $form_profession->get('email')->getData();
  314.             $message $form_profession->get('message')->getData();
  315.             // Vérifier si l'email est dans la blacklist
  316.             $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  317.             if (!($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) && stripos($message"free") === false) {
  318.                 $this->CE->sendContactProfessionEmail($form_profession);
  319.             } elseif ($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) {
  320.                 // Incrémenter le compteur de tentatives
  321.                 $blacklistedEmail $blacklistRepo->findByEmail($email);
  322.                 if ($blacklistedEmail) {
  323.                     $blacklistedEmail->incrementBlockCount();
  324.                     $entityManager $this->getDoctrine()->getManager();
  325.                     $entityManager->persist($blacklistedEmail);
  326.                     $entityManager->flush();
  327.                 }
  328.             }
  329.             $this->form_send_profession true;
  330.         }
  331.         // etre rappele
  332.         $form_etre_rappele $this->createForm(ContactEtreRappeleType::class, null, ['cabinet' => $this->accountingFirm]);
  333.         $form_etre_rappele->handleRequest($request);
  334.         $this->formetrerappeleview $form_etre_rappele->createView();
  335.         if ($form_etre_rappele->isSubmitted() && $form_etre_rappele->isValid())
  336.         {
  337.             $name $form_etre_rappele->get('name')->getData();
  338.             $email $form_etre_rappele->get('email')->getData();
  339.             // Vérifier si l'email est dans la blacklist
  340.             $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  341.             if (!($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name))) {
  342.                 $this->CE->sendContactEtreRappeleEmail($form_etre_rappele);
  343.             } elseif ($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) {
  344.                 // Incrémenter le compteur de tentatives
  345.                 $blacklistedEmail $blacklistRepo->findByEmail($email);
  346.                 if ($blacklistedEmail) {
  347.                     $blacklistedEmail->incrementBlockCount();
  348.                     $entityManager $this->getDoctrine()->getManager();
  349.                     $entityManager->persist($blacklistedEmail);
  350.                     $entityManager->flush();
  351.                 }
  352.             }
  353.             $this->form_send_etreRappele true;
  354.         }
  355. // previ creation
  356.         $logFile $this->getParameter('kernel.project_dir') . '/var/log/monprevi.log';
  357.         if (!is_dir(dirname($logFile))) {
  358.             @mkdir(dirname($logFile), 0775true);
  359.         }
  360.         $log = function (string $message) use ($logFile) {
  361.             @file_put_contents(
  362.                 $logFile,
  363.                 sprintf("[%s] %s\n", (new \DateTimeImmutable())->format('Y-m-d H:i:s'), $message),
  364.                 FILE_APPEND
  365.             );
  366.         };
  367.         if ($this->accountingFirm->getId() === 301 || $this->accountingFirm->getId() === 320) {
  368.             $log("Init Previ Creation: host={$this->theHost}, cabinet_id=" . ($this->accountingFirm $this->accountingFirm->getId() : 'null'));
  369.         }
  370.         try {
  371.             $contactCreationSociete = new ContactCreationSociete();
  372.             $contactCreationSociete->setCabinet($this->accountingFirm);
  373.             $contactCreationSociete->setCreatedAt(new \DateTimeImmutable('now'));
  374.             $form_previcreation $this->createForm(ContactCreationSocieteType::class, $contactCreationSociete, ['cabinet' => $this->accountingFirm]);
  375.             $this->formprevicreationview $form_previcreation->createView();
  376.             if ($this->accountingFirm->getId() === 301) {
  377.                 $log("Previ Creation : Formulaire affiché");
  378.             }
  379.             if ($request->isMethod('POST') && $request->request->has($form_previcreation->getName())) {
  380.                 $log("Previ Creation POST detecté pour form=" $form_previcreation->getName());
  381.                 $form_previcreation->handleRequest($request);
  382.                 if ($form_previcreation->isSubmitted() && $form_previcreation->isValid()) {
  383.                     $log("Previ Creation formulaire soumis et valide");
  384.                     $startActivityAt $form_previcreation->get('startActivityAt')->getData();
  385.                     $fiscalYearEndAt $form_previcreation->get('fiscalYearEndAt')->getData();
  386.                     $log(sprintf(
  387.                         "Previ Creation dates reçues: startActivityAt=%s, fiscalYearEndAt=%s",
  388.                         $startActivityAt $startActivityAt->format('d/m/Y') : 'null',
  389.                         $fiscalYearEndAt $fiscalYearEndAt->format('d/m/Y') : 'null'
  390.                     ));
  391.                     $contactCreationSociete->setStartActivityAt($startActivityAt);
  392.                     $contactCreationSociete->setFiscalYearEndAt($fiscalYearEndAt);
  393.                     $name $form_previcreation->get('name')->getData();
  394.                     $email $form_previcreation->get('email')->getData();
  395.                     $log("Previ Creation nom reçu: {$name} {$email}");
  396.                     // Vérifier si l'email est dans la blacklist
  397.                     $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  398.                     if (!($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name))) {
  399.                         $log("Blacklist check passed for email: {$email}");
  400.                         try {
  401.                             $entityManager->persist($contactCreationSociete);
  402.                             $entityManager->flush();
  403.                         } catch (\Throwable $e) {
  404.                             $this->logger->error("❌ Erreur lors du persist/flush Previ Creation", [
  405.                                 'message' => $e->getMessage(),
  406.                                 'trace' => $e->getTraceAsString(),
  407.                                 'form_data_class' => get_class($form_previcreation->getData()),
  408.                                 'form_valid' => $form_previcreation->isValid(),
  409.                                 'form_errors' => (string) $form_previcreation->getErrors(truefalse),
  410.                             ]);
  411.                             throw $e;
  412.                         }
  413.                         $log("Previ Creation entité persistée id=" $contactCreationSociete->getId());
  414.                         $contactCreationSociete->setReference('PREVI_' $contactCreationSociete->getId());
  415.                         $entityManager->persist($contactCreationSociete);
  416.                         $entityManager->flush();
  417.                         $log("Previ Creation référence définie=" $contactCreationSociete->getReference());
  418.                         if ($contactCreationSociete->getPaymentMethod() === 'cb') {
  419.                             $parameters $this->accountingFirm->getParameters();
  420.                             $price = ($contactCreationSociete->getCategory() == "Prévisionnel complet") ? "359,00" "259,00";
  421.                             $urlRetour $this->generateUrl('monetico_return_client', ['id' => $contactCreationSociete->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
  422.                             $urlNotif $this->generateUrl('monetico_notification', [], UrlGeneratorInterface::ABSOLUTE_URL);
  423.                             if (str_contains($this->request->getCurrentRequest()->get('_route'), 'preview')) {
  424.                                 $urlRetour $this->generateUrl('previewmonetico_return_client', ['host' => $this->theHost'id' => $contactCreationSociete->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
  425.                                 $urlNotif $this->generateUrl('previewmonetico_notification', ['host' => $this->theHost], UrlGeneratorInterface::ABSOLUTE_URL);
  426.                             }
  427.                             $log("Previ Creation paiement CB: price={$price}, reference=" $contactCreationSociete->getReference() . ", url_retour={$urlRetour}, url_notif={$urlNotif}");
  428.                             $params = [
  429.                                 'tpe'         => $parameters->getMoneticoTpe(),
  430.                                 'societe'     => $parameters->getMoneticoSociete(),
  431.                                 'hmac_key'    => $parameters->getMoneticoCle(),
  432.                                 'url_retour'  => $urlRetour,
  433.                                 'url_notif'   => $urlNotif,
  434.                                 'montant'     => $price,
  435.                                 'reference'   => $contactCreationSociete->getReference(),
  436.                                 'email'       => $contactCreationSociete->getEmail(),
  437.                                 'name'        => $contactCreationSociete->getName(),
  438.                                 'firstname'   => $contactCreationSociete->getFirstname(),
  439.                                 'address'     => $contactCreationSociete->getSocietyAddress(),
  440.                                 'zipCode'     => $contactCreationSociete->getSocietyZipCode(),
  441.                                 'city'        => $contactCreationSociete->getSocietyCity(),
  442.                             ];
  443.                             $log("Previ Creation génération du formulaire de paiement Monetico");
  444.                             return new Response($this->moneticoService->generatePaymentForm($params));
  445.                         }
  446.                         $this->CE->sendPreviCreation($contactCreationSociete);
  447.                         $this->form_send_previ_creation true;
  448.                         $log("Previ Creation email envoyé, référence=" $contactCreationSociete->getReference());
  449.                         $urlRetour $this->generateUrl('monetico_return_client', ['id' => $contactCreationSociete->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
  450.                         if (str_contains($this->request->getCurrentRequest()->get('_route'), 'preview')) {
  451.                             $urlRetour $this->generateUrl('previewmonetico_return_client', ['host' => $this->theHost'id' => $contactCreationSociete->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
  452.                         }
  453.                         $urlRetour .= "?reference=" $contactCreationSociete->getReference();
  454.                         $urlRetour .= "&code-retour=paiement";
  455.                         $log("Previ Creation redirection vers {$urlRetour}");
  456.                         return new RedirectResponse($urlRetour);
  457.                     } elseif ($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) {
  458.                         $blacklistedEmail $blacklistRepo->findByEmail($email);
  459.                         if ($blacklistedEmail) {
  460.                             $blacklistedEmail->incrementBlockCount();
  461.                             $entityManager->persist($blacklistedEmail);
  462.                             $entityManager->flush();
  463.                         }
  464.                         $log("Previ Creation email blacklisté: {$email}");
  465.                     }
  466.                 } else {
  467.                     $log("Previ Creation formulaire non valide ou non soumis");
  468.                     $this->logger->error("Previ Creation formulaire non valide ou non soumis", [
  469.                         'form_data_class' => get_class($form_previcreation->getData()),
  470.                         'form_valid' => $form_previcreation->isValid(),
  471.                         'form_errors' => (string) $form_previcreation->getErrors(truefalse),
  472.                     ]);
  473.                 }
  474.             }
  475.         } catch (\Throwable $e) {
  476.             // ⚙️ On tente de récupérer le contenu du formulaire, même s'il est invalide
  477.             $formData = [];
  478.             try {
  479.                 if (isset($form_previcreation) && $form_previcreation->isSubmitted()) {
  480.                     // on extrait les données brutes + erreurs
  481.                     $formData = [
  482.                         'data' => $form_previcreation->getData(),
  483.                         'submitted_data' => $request->request->all($form_previcreation->getName()),
  484.                         'errors' => (string) $form_previcreation->getErrors(truefalse),
  485.                     ];
  486.                 }
  487.             } catch (\Throwable $innerE) {
  488.                 // on logue aussi si jamais même la récupération échoue (par sécurité)
  489.                 $this->logger->warning('Impossible d’extraire les données du formulaire dans le catch', [
  490.                     'inner_message' => $innerE->getMessage(),
  491.                 ]);
  492.             }
  493.             // 🧾 Log complet de l’exception
  494.             $this->logger->error('❌ Exception non interceptée dans Previ Creation', [
  495.                 'message' => $e->getMessage(),
  496.                 'trace' => $e->getTraceAsString(),
  497.                 'file' => $e->getFile(),
  498.                 'line' => $e->getLine(),
  499.                 'request_uri' => $request->getRequestUri(),
  500.                 'form_data' => $formData,
  501.             ]);
  502.             // 🔁 selon ton besoin :
  503.              throw $e// pour laisser Symfony gérer l'erreur (page 500)
  504.         }
  505.         // previ immo
  506.         if ($this->accountingFirm->getId() === 301) {
  507.             $log("Init Previ Immo: host={$this->theHost}, cabinet_id=" . ($this->accountingFirm $this->accountingFirm->getId() : 'null'));
  508.         }
  509.         try {
  510.             $contactInvestissementImmo = new ContactInvestissementImmo();
  511.             $contactInvestissementImmo->setAccountingFirm($this->accountingFirm);
  512.             $contactInvestissementImmo->setNumberProperties(1);
  513.             $contactInvestissementImmo->setCreatedAt(new \DateTimeImmutable('now'));
  514.             $form_previimmo $this->createForm(ContactInvestissementImmoType::class, $contactInvestissementImmo, ['cabinet' => $this->accountingFirm]);
  515.             $this->formpreviimmoview $form_previimmo->createView();
  516.             if ($this->accountingFirm->getId() === 301) {
  517.                 $log("Previ Immo : Formulaire affiché");
  518.             }
  519.             if ($request->isMethod('POST') && $request->request->has($form_previimmo->getName())) {
  520.                 $log("Previ Immo POST détecté pour form=" $form_previimmo->getName());
  521.                 $form_previimmo->handleRequest($request);
  522.                 if ($form_previimmo->isSubmitted() && $form_previimmo->isValid()) {
  523.                     $log("Previ Immo formulaire soumis et valide");
  524.                     $name $form_previimmo->get('name')->getData();
  525.                     $email $form_previimmo->get('email')->getData();
  526.                     $log("Previ Immo nom reçu: {$name} {$email}");
  527.                     $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  528.                     if (!($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name))) {
  529.                         $propertiesImmoData $form_previimmo->get('propertiesImmo')->getData();
  530.                         $propertiesChargesData $form_previimmo->get('propertiesCharges')->getData();
  531.                         $propertiesRentData $form_previimmo->get('propertiesRent')->getData();
  532.                         $log("Previ Immo propriétés reçues: nb=" . (is_iterable($propertiesImmoData) ? count($propertiesImmoData) : 0));
  533.                         foreach ($propertiesImmoData as $index => $propertyData) {
  534.                             $log("Previ Immo propriété index={$index} création");
  535.                             $property = new ContactInvestissementImmoProperty();
  536.                             $property->setSurface($propertyData['surface'] ?? '');
  537.                             $property->setBiens($propertyData['biens'] ?? '');
  538.                             $property->setRents($propertiesRentData[$index]['rent'] ?? '');
  539.                             $property->setContactInvestissementImmo($contactInvestissementImmo);
  540.                             if (isset($propertiesChargesData[$index]['charges']) && is_iterable($propertiesChargesData[$index]['charges'])) {
  541.                                 $log("Previ Immo propriété index={$index} charges nb=" count($propertiesChargesData[$index]['charges']));
  542.                                 foreach ($propertiesChargesData[$index]['charges'] as $chargeData) {
  543.                                     $charge = new ContactInvestissementImmoPropertyCharge();
  544.                                     $charge->setName($chargeData['name'] ?? '');
  545.                                     $charge->setAmount($chargeData['amount'] ?? '');
  546.                                     $charge->setFrequency($chargeData['periodicite'] ?? '');
  547.                                     $charge->setContactInvestissementImmoProperty($property);
  548.                                     $entityManager->persist($charge);
  549.                                     $property->addCharge($charge);
  550.                                 }
  551.                             }
  552.                             $entityManager->persist($property);
  553.                             $contactInvestissementImmo->getProperties()->add($property);
  554.                         }
  555.                         try {
  556.                             $entityManager->persist($contactInvestissementImmo);
  557.                             $entityManager->flush();
  558.                         } catch (\Throwable $e) {
  559.                             $this->logger->error("❌ Erreur lors du persist/flush Previ Immo", [
  560.                                 'message' => $e->getMessage(),
  561.                                 'trace' => $e->getTraceAsString(),
  562.                                 'form_data_class' => get_class($form_previimmo->getData()),
  563.                                 'form_valid' => $form_previimmo->isValid(),
  564.                                 'form_errors' => (string) $form_previimmo->getErrors(truefalse),
  565.                             ]);
  566.                             throw $e;
  567.                         }
  568.                         $log("Previ Immo entité persistée id=" $contactInvestissementImmo->getId());
  569.                         $contactInvestissementImmo->setReference('PREVI_IMMO_' $contactInvestissementImmo->getId());
  570.                         $entityManager->persist($contactInvestissementImmo);
  571.                         $entityManager->flush();
  572.                         $log("Previ Immo référence définie=" $contactInvestissementImmo->getReference());
  573.                         if ($contactInvestissementImmo->getPaymentMethod() === 'cb') {
  574.                             $parameters $this->accountingFirm->getParameters();
  575.                             $price "259,00";
  576.                             $urlRetour $this->generateUrl('monetico_return_client', ['id' => $contactInvestissementImmo->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
  577.                             $urlNotif $this->generateUrl('monetico_notification', [], UrlGeneratorInterface::ABSOLUTE_URL);
  578.                             if (str_contains($this->request->getCurrentRequest()->get('_route'), 'preview')) {
  579.                                 $urlRetour $this->generateUrl('previewmonetico_return_client', ['host' => $this->theHost'id' => $contactInvestissementImmo->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
  580.                                 $urlNotif $this->generateUrl('previewmonetico_notification', ['host' => $this->theHost], UrlGeneratorInterface::ABSOLUTE_URL);
  581.                             }
  582.                             $log("Previ Immo paiement CB: price={$price}, reference=" $contactInvestissementImmo->getReference());
  583.                             $params = [
  584.                                 'tpe'         => $parameters->getMoneticoTpe(),
  585.                                 'societe'     => $parameters->getMoneticoSociete(),
  586.                                 'hmac_key'    => $parameters->getMoneticoCle(),
  587.                                 'url_retour'  => $urlRetour,
  588.                                 'url_notif'   => $urlNotif,
  589.                                 'montant'     => $price,
  590.                                 'reference'   => $contactInvestissementImmo->getReference(),
  591.                                 'email'       => $contactInvestissementImmo->getEmail(),
  592.                                 'name'        => $contactInvestissementImmo->getName(),
  593.                                 'firstname'   => $contactInvestissementImmo->getFirstname(),
  594.                                 'address'     => $contactInvestissementImmo->getAdress(),
  595.                                 'zipCode'     => $contactInvestissementImmo->getZipCode(),
  596.                                 'city'        => $contactInvestissementImmo->getCity(),
  597.                             ];
  598.                             $log("Previ Immo génération du formulaire de paiement Monetico");
  599.                             return new Response($this->moneticoService->generatePaymentForm($params));
  600.                         }
  601.                         $this->CE->sendPreviImmo($contactInvestissementImmo);
  602.                         $this->form_send_previ_immo true;
  603.                         $log("Previ Immo email envoyé, référence=" $contactInvestissementImmo->getReference());
  604.                         $urlRetour $this->generateUrl('monetico_return_client', ['id' => $contactInvestissementImmo->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
  605.                         if (str_contains($this->request->getCurrentRequest()->get('_route'), 'preview')) {
  606.                             $urlRetour $this->generateUrl('previewmonetico_return_client', ['host' => $this->theHost'id' => $contactInvestissementImmo->getId()], UrlGeneratorInterface::ABSOLUTE_URL);
  607.                         }
  608.                         $urlRetour .= "?reference=" $contactInvestissementImmo->getReference();
  609.                         $urlRetour .= "&code-retour=paiement";
  610.                         $log("Previ Immo redirection vers {$urlRetour}");
  611.                         return new RedirectResponse($urlRetour);
  612.                     } else {
  613.                         $blacklistedEmail $blacklistRepo->findByEmail($email);
  614.                         if ($blacklistedEmail) {
  615.                             $blacklistedEmail->incrementBlockCount();
  616.                             $entityManager->persist($blacklistedEmail);
  617.                             $entityManager->flush();
  618.                         }
  619.                         $log("Previ Immo email blacklisté: {$email}");
  620.                     }
  621.                 } else {
  622.                     $log("Previ Immo formulaire non valide ou non soumis");
  623.                 }
  624.             }
  625.         } catch (\Throwable $e) {
  626.             // 🧾 Récupération sécurisée du contenu du formulaire
  627.             $formData = [];
  628.             try {
  629.                 if (isset($form_previimmo) && $form_previimmo->isSubmitted()) {
  630.                     $formData = [
  631.                         'data' => $form_previimmo->getData(),
  632.                         'submitted_data' => $request->request->all($form_previimmo->getName()),
  633.                         'errors' => (string) $form_previimmo->getErrors(truefalse),
  634.                     ];
  635.                 }
  636.             } catch (\Throwable $innerE) {
  637.                 $this->logger->warning('Impossible d’extraire les données du formulaire Previ Immo', [
  638.                     'inner_message' => $innerE->getMessage(),
  639.                 ]);
  640.             }
  641.             // 🔥 Log complet de l’exception
  642.             $this->logger->error('❌ Exception non interceptée dans Previ Immo', [
  643.                 'message' => $e->getMessage(),
  644.                 'trace' => $e->getTraceAsString(),
  645.                 'file' => $e->getFile(),
  646.                 'line' => $e->getLine(),
  647.                 'request_uri' => $request->getRequestUri(),
  648.                 'form_data' => $formData,
  649.             ]);
  650.             return new Response("Une erreur interne est survenue"500);
  651.         }
  652.         // newsletter
  653.         $form_newsletter $this->createForm(NewsletterType::class, null, ['cabinet' => $this->accountingFirm]);
  654.         $form_newsletter->handleRequest($request);
  655.         $this->formnewsletterview $form_newsletter->createView();
  656.         if ($form_newsletter->isSubmitted() && $form_newsletter->isValid()) {
  657.             $name $form_newsletter->get('name')->getData();
  658.             $email $form_newsletter->get('email')->getData();
  659.             // Vérifier si l'email est dans la blacklist
  660.             $blacklistRepo $this->getDoctrine()->getRepository(EmailBlacklist::class);
  661.             if (!($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name))) {
  662.                 $this->CE->sendNewsletterEmail($form_newsletter);
  663.             } elseif ($blacklistRepo->isEmailBlacklisted($email) || $blacklistRepo->isEmailBlacklisted($name)) {
  664.                 // Incrémenter le compteur de tentatives
  665.                 $blacklistedEmail $blacklistRepo->findByEmail($email);
  666.                 if ($blacklistedEmail) {
  667.                     $blacklistedEmail->incrementBlockCount();
  668.                     $entityManager $this->getDoctrine()->getManager();
  669.                     $entityManager->persist($blacklistedEmail);
  670.                     $entityManager->flush();
  671.                 }
  672.             }
  673.             $this->form_send_newsletter true;
  674.         }
  675.         // minibook
  676.         $form_minibook $this->createForm(MiniBookType::class);
  677.         $form_minibook->handleRequest($request);
  678.         $this->formminibookview $form_minibook->createView();
  679.         if ($form_minibook->isSubmitted() && $form_minibook->isValid()) {
  680.             $this->CE->sendMiniEbookEmail($form_minibook);
  681.             $this->form_send_minibook true;
  682.         }
  683.         // recrutement
  684.         $form_recrutement $this->createForm(AnnouncementApplyType::class, null, ['cabinet' => $this->accountingFirm]);
  685.         $form_recrutement->handleRequest($request);
  686.         $this->formrecrutementview $form_recrutement->createView();
  687.         if ($form_recrutement->isSubmitted() && $form_recrutement->isValid()) {
  688.             $this->CE->sendRecrutementEmail($form_recrutement);
  689.             $this->form_send_recrutement true;
  690.         }
  691.         // Setup return data
  692.         $parameters['accountingFirm'] = $parameters['cabinet'] = $this->accountingFirm;
  693.         $parameters['parameters'] = $this->accountingFirm->getParameters();
  694.         $parameters['form'] = $this->formview;
  695.         $parameters['form_send'] = $this->formsend;
  696.         $parameters['form_livre'] = $this->formlivreview;
  697.         $parameters['form_send_livre'] = $this->form_send_livre;
  698.         $parameters['form_company'] = $this->formcompanyview;
  699.         $parameters['form_send_company'] = $this->form_send_company;
  700.         $parameters['form_newsletter'] = $this->formnewsletterview;
  701.         $parameters['form_send_newsletter'] = $this->form_send_newsletter;
  702.         $parameters['form_minibook'] = $this->formminibookview;
  703.         $parameters['form_send_minibook'] = $this->form_send_minibook;
  704.         $parameters['form_recrutement'] = $this->formrecrutementview;
  705.         $parameters['form_send_recrutement'] = $this->form_send_recrutement;
  706.         $parameters['form_profession'] = $this->formprofessionview;
  707.         $parameters['form_send_profession'] = $this->form_send_profession;
  708.         $parameters['form_etre_rappele'] = $this->formetrerappeleview;
  709.         $parameters['form_send_etre_rappele'] = $this->form_send_etreRappele;
  710.         $parameters['form_custom'] = $this->formcustomview;
  711.         $parameters['form_send_custom'] = $this->form_send_custom;
  712.         $parameters['form_previ_creation'] = $this->formprevicreationview;
  713.         $parameters['form_send_previ_creation'] = $this->form_send_previ_creation;
  714.         $parameters['form_previ_immo'] = $this->formpreviimmoview;
  715.         $parameters['form_send_previ_immo'] = $this->form_send_previ_immo;
  716.         if (isset($this->announcementMain[0])) {
  717.             $parameters['announcementMain'] = $this->announcementMain[0];
  718.         }
  719.         if (isset($this->announcementSpontanee[0])) {
  720.             $parameters['announcementSpontanee'] = $this->announcementSpontanee[0];
  721.         }
  722.         $parameters["DynData"] = [];
  723.         // ✅ OPTIMISATION : Éviter count() dans la boucle et appels répétés aux getters
  724.         // Utilisation de foreach au lieu de for avec count()
  725.         foreach ($this->dynDataText as $dynDataItem) {
  726.             $name $dynDataItem->getName();
  727.             $key str_replace(' ''-'strtolower($name));
  728.             $parameters["DynData"][$key] = [
  729.                 'name' => $name,
  730.                 'data' => $dynDataItem->getData(),
  731.                 'type' => $dynDataItem->getType(),
  732.             ];
  733.         }
  734.         foreach ($this->dynDataArray as $dynDataItem) {
  735.             $name $dynDataItem->getName();
  736.             $dataItems $dynDataItem->getDataItems();
  737.             $dataItemsArray = [];
  738.             foreach ($dataItems as $item) {
  739.                 $dataItemsArray[] = [
  740.                     'titre' => $item->getTitle(),
  741.                     'data' => $item->getData(),
  742.                 ];
  743.             }
  744.             $key str_replace(' ''-'strtolower($name));
  745.             $parameters["DynData"][$key] = [
  746.                 'name' => $name,
  747.                 'data' => $dataItemsArray,
  748.                 'type' => $dynDataItem->getType(),
  749.             ];
  750.         }
  751.         $host $this->request->getCurrentRequest()->getHost();
  752.         if (in_array($host, ['prod.lagence.expert''frontdev.lagence.expert''127.0.0.1'])) {
  753.             return parent::render($this->templateBase $view$parameters$response);
  754.         } else if ($this->accountingFirm->getParameters()->isMaintenance()) {
  755.             return parent::render("/maintenance.html.twig"$parameters$response);
  756.         } else if ($this->accountingFirm->getParameters()->isConstruction()) {
  757.             return parent::render("/maintenance.html.twig"$parameters$response);
  758.         } else {
  759.             return parent::render($this->templateBase $view$parameters$response);
  760.         }
  761.     }
  762.     private function isGibberishMessage(string $message): bool
  763.     {
  764.         $message trim($message);
  765.         // Trop court = on laisse passer
  766.         if (mb_strlen($message) < 10) {
  767.             return false;
  768.         }
  769.         // Aucun espace → très suspect
  770.         if (strpos($message' ') === false) {
  771.             // Uniquement lettres/chiffres
  772.             if (preg_match('/^[a-zA-Z0-9]+$/'$message)) {
  773.                 return true;
  774.             }
  775.         }
  776.         // Ratio voyelles / longueur
  777.         preg_match_all('/[aeiouyAEIOUY]/'$message$matches);
  778.         $vowelCount count($matches[0]);
  779.         $length mb_strlen($message);
  780.         if ($vowelCount $length 0.2) {
  781.             return true;
  782.         }
  783.         return false;
  784.     }
  785.     protected function redirectRouteV2(Request $requeststring $prefix null): ?string
  786.     {
  787.         $redirect null;
  788.         $p $request->getRequestUri();
  789.         $pos strpos($p'?');
  790.         if ($pos !== false) {
  791.             $p substr($p0$pos 1) . str_replace('?''&'substr($p$pos 1));
  792.         }
  793.         $route parse_url($p);
  794.         if (isset($route['query'])) {
  795.             parse_str($route['query'], $query);
  796.             $page = isset($query['p']) ? $query['p'] : null;
  797.             $id = isset($query['id']) ? $query['id'] : null;
  798.             $date = isset($query['date']) ? $query['date'] : null;
  799.             $search = isset($query['q']) ? $query['q'] : null;
  800.             if (!empty($page) && !is_null($page)) {
  801.                 switch ($page) {
  802.                     case 'transformation-digitale.php':
  803.                         if (!empty($id) && !is_null($id)) {
  804.                             $redirect $this->generateUrl('client_widget_transformation_digitale_show', ['id' => $id'slug' => 'actualite']);
  805.                         } else {
  806.                             $redirect $this->generateUrl('client_widget_transformation_digitale_noid');
  807.                         }
  808.                         break;
  809.                     case 'calendrier-fiscal.php':
  810.                         if (!empty($id) && !is_null($id)) {
  811.                             $redirect $this->generateUrl('client_widget_news_fisc_show', ['id' => $id]);
  812.                         }
  813.                         break;
  814.                     case 'actualites-calendrier-fiscal.php':
  815.                         if (!empty($date) && !is_null($date)) {
  816.                             $redirect $this->generateUrl('client_widget_news_fisc_list_show', ['date' => $date]);
  817.                         }
  818.                         break;
  819.                     case 'actualite.php':
  820.                         if (!empty($id) && !is_null($id)) {
  821.                             $redirect $this->generateUrl('client_widget_news_juri_show', ['id' => $id'slug' => 'actualite']);
  822.                         }
  823.                         break;
  824.                     case 'bien-etre.php':
  825.                         if (!empty($id) && !is_null($id)) {
  826.                             $redirect $this->generateUrl('client_widget_bien_etre_show', ['id' => $id'slug' => 'actualite']);
  827.                         } else {
  828.                             $redirect $this->generateUrl('client_widget_bien_etre_noid');
  829.                         }
  830.                         break;
  831.                     case 'actualite-cabinet.php':
  832.                         if (!empty($id) && !is_null($id)) {
  833.                             $redirect $this->generateUrl('client_widget_news_cabinet_show', ['id' => $id'slug' => 'actualite']);
  834.                         }
  835.                         break;
  836.                     case 'recherche.php':
  837.                         if (!empty($search) && !is_null($search)) {
  838.                             $redirect $this->generateUrl('client_widget_recherche', ['q' => $search]);
  839.                         }
  840.                         break;
  841.                     case 'podcast.php':
  842.                         if (!empty($id) && !is_null($id)) {
  843.                             $redirect $this->generateUrl('client_widget_podcast_detail', ['id' => $id]);
  844.                         } else {
  845.                             $redirect $this->generateUrl('client_widget_podcast_detail', ['id' => "list"]);
  846.                         }
  847.                         break;
  848.                     case 'podcast-latest.php':
  849.                             $podcats_latest $this->serviceQMV2->getPodcastLatest();
  850.                             $redirect $this->generateUrl('client_widget_podcast_detail', ['id' => $podcats_latest[0]->getId()]);
  851.                         break;
  852.                     case 'infographie-rse.php':
  853.                         if (!empty($id) && !is_null($id)) {
  854.                             $redirect $this->generateUrl('client_widget_infographie_rse_detail', ['id' => $id]);
  855.                         } else {
  856.                             $redirect $this->generateUrl('client_widget_infographie_rse_detail_noid');
  857.                         }
  858.                         break;
  859.                     case 'participation.php':
  860.                         $redirect $this->generateUrl('client_widget_participation_pal');
  861.                         break;
  862.                     case 'journal.php':
  863.                         if (!empty($id) && !is_null($id)) {
  864.                             $redirect $this->generateUrl('client_widget_journal_show', ['id' => $id]);
  865.                         } else {
  866.                             $redirect $this->generateUrl('client_widget_journal_noid');
  867.                         }
  868.                         break;
  869.                     case 'aide.php':
  870.                         if (!empty($id) && !is_null($id)) {
  871.                             $redirect $this->generateUrl('client_widget_aide_show', ['id' => $id]);
  872.                         } else {
  873.                             $redirect $this->generateUrl('client_widget_aide_noid');
  874.                         }
  875.                         break;
  876.                     case 'calendrier-juridique.php':
  877.                         if ($date) {
  878.                             $redirect $this->generateUrl('client_widget_news_fisc_list_show', ['date' => $date]);
  879.                         } else {
  880.                             $redirect $this->generateUrl('client_widget_calendrier_show');
  881.                         }
  882.                         break;
  883.                     default:
  884.                         // NOPE
  885.                         break;
  886.                 }
  887.             }
  888.         }
  889.         return $redirect $prefix $redirect $redirect;
  890.     }
  891. }