src/Controller/Vitrine/PagesController.php line 231

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Vitrine;
  3. use App\Entity\Core\Users;
  4. use App\Entity\Fiches\Articles;
  5. use App\Entity\Fiches\Interactions;
  6. use App\Entity\Pages\Contents;
  7. use App\Entity\Pages\Pages;
  8. use App\Entity\Pages\PagesHasBlocks;
  9. use App\Entity\Pages\SecureContent;
  10. use App\Entity\Pages\SimulationContent;
  11. use App\Entity\Pages\SimulationContentCategories;
  12. use App\Entity\Pages\SimulationContentHasCheck;
  13. use App\Form\Fiches\InteractionsAdminForm;
  14. use App\Form\Fiches\InteractionsForm;
  15. use App\Form\Fiches\InteractionsSimpleForm;
  16. use App\Form\Pages\BeforeSecureContentsForm;
  17. use App\Form\Pages\ReportingEmailForm;
  18. use App\Services\EncryptionService;
  19. use Symfony\Component\HttpFoundation\Request;
  20. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  21. use Symfony\Component\HttpFoundation\Session\Session;
  22. use Symfony\Component\Filesystem\Filesystem;
  23. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  24. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  25. use Symfony\Component\HttpFoundation\StreamedResponse;
  26. use Symfony\Component\HttpFoundation\Response;
  27. use Symfony\Component\HttpFoundation\JsonResponse;
  28. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  29. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  30. use Symfony\Component\Form\Extension\Core\Type\TextType;
  31. use Doctrine\ORM\EntityManagerInterface;
  32. use Psr\Log\LoggerInterface;
  33. /**
  34.  * Gestion des pages
  35.  */
  36. class PagesController extends AbstractController
  37. {
  38.     private $em;
  39.     private $us;
  40.     private $es;
  41.     private $decryptionLogger;
  42.     public function __construct(EntityManagerInterface $em,
  43.                                 \App\Services\Core\Users $us,
  44.                                 EncryptionService $es,
  45.                                 LoggerInterface $decryptionLogger
  46.     ){
  47.         $this->em $em;
  48.         $this->us $us;
  49.         $this->es $es;
  50.         $this->decryptionLogger $decryptionLogger;
  51.     }
  52.     /**
  53.      * Moteur de recherche
  54.      * @param Request $request
  55.      * @return mixed
  56.      */
  57.     public function search(Request $request)
  58.     {
  59.         $themeSelection $_ENV['THEME_BLOG'];
  60.         $session $request->getSession();
  61.         $locale $request->getLocale();
  62.         $page $this->em->getRepository(Pages::class)->findOneBy(['name' => 'search''locale' => $locale]);
  63.         $searchTerm "";
  64.         if(isset($_GET['search'])) {
  65.             $searchTerm $_GET['search'];
  66.         }
  67.         $articles $this->em->getRepository(\App\Entity\Articles\Articles::class)->getSearch("fr",$searchTerm);
  68.         $contents $this->em->getRepository(Contents::class)->getSearch($searchTerm);
  69.         $pages $this->em->getRepository(Pages::class)->getSearch($searchTerm);
  70.         $premiums $this->em->getRepository(Articles::class)->getSearch($searchTerm);
  71.         return $this->render('vitrine/'.$themeSelection.'/search.html.twig',[
  72.             'page' => $page,
  73.             'pages' => $pages,
  74.             'search' => $searchTerm,
  75.             'articles' => $articles,
  76.             'contents' => $contents,
  77.             'premiums' => $premiums
  78.         ]);
  79.     }
  80.     /**
  81.      * 1er niveau
  82.      * @param Request $request
  83.      * @param $folderslug
  84.      * @return mixed
  85.      */
  86.     public function fiche(Request $request$folderslug)
  87.     {
  88.         $themeSelection $_ENV['THEME_BLOG'];
  89.         $session $request->getSession();
  90.         $locale $request->getLocale();
  91.         // Mode TEST
  92.         if($_ENV['APP_ENV'] !== "prod") {
  93.             if($folderslug === "test") {
  94.                 $page $this->em->getRepository(Pages::class)->findOneBy(['name' => 'test']);
  95.                 return $this->render('vitrine/'.$themeSelection.'/page_test.html.twig',['page' => $page]);
  96.             }
  97.         }
  98.         // Article sur une page.
  99.         $pageArticle $this->em->getRepository(\App\Entity\Articles\Articles::class)->getPage($locale,$folderslug);
  100.         if($pageArticle !== null) {
  101.             return $this->render('vitrine/'.$themeSelection.'/page_article.html.twig', [
  102.                 'article' => $pageArticle
  103.             ]);
  104.         }
  105.         // Simulation de projets
  106.         $contentSC $this->em->getRepository(SimulationContent::class)->findOneBy(['locale' => $locale'identifiant' => $folderslug]);
  107.         if ($contentSC) {
  108.             $checks $this->em->getRepository(SimulationContentHasCheck::class)->findBy(['simulationContent' => $contentSC->getId()]);
  109.             $categories $this->em->getRepository(SimulationContentCategories::class)->findBy(['simulationContent' => $contentSC->getId()]);
  110.             $categoriesOn $this->em->getRepository(SimulationContentCategories::class)->findBy(['simulationContent' => $contentSC->getId(),'onQuotation' => true'details' => true]);
  111.             $categoriesOff $this->em->getRepository(SimulationContentCategories::class)->findBy(['simulationContent' => $contentSC->getId(),'onQuotation' => false'details' => true]);
  112.             return $this->render('vitrine/'.$themeSelection.'/page_simulation.html.twig', [
  113.                 'content' => $contentSC,
  114.                 'checks' => $checks,
  115.                 'categories' => $categories,
  116.                 'categoriesOn' => $categoriesOn,
  117.                 'categoriesOff' => $categoriesOff
  118.             ]);
  119.         }
  120.         // Contenu chiffré.
  121.         $contentS $this->em->getRepository(SecureContent::class)->findOneBy(['locale' => $locale'identifiant' => $folderslug]);
  122.         if ($contentS) {
  123.             $attemptKey 'decrypt_attempts_' $folderslug;
  124.             $maxAttempts 5;
  125.             $lockoutTime 60// Temps de verrouillage en secondes (1 minute)
  126.             // Vérifiez si l'utilisateur est temporairement verrouillé
  127.             if ($session->has($attemptKey '_lockout_time') && time() < $session->get($attemptKey '_lockout_time')) {
  128.                 return $this->render('vitrine/'.$themeSelection.'/secure/lockout.html.twig', [
  129.                     'lockout_time' => $session->get($attemptKey '_lockout_time') - time(),
  130.                     'content' => $contentS,
  131.                     'folderslug' => $folderslug
  132.                 ]);
  133.             }
  134.             $attempts $session->get($attemptKey0);
  135.             if ($attempts >= $maxAttempts) {
  136.                 // Verrouillez l'accès pour un certain temps
  137.                 $session->set($attemptKey '_lockout_time'time() + $lockoutTime);
  138.                 $session->remove($attemptKey); // Réinitialisez le compteur de tentatives
  139.                 return $this->render('vitrine/'.$themeSelection.'/secure/lockout.html.twig', [
  140.                     'lockout_time' => $lockoutTime,
  141.                     'content' => $contentS,
  142.                     'folderslug' => $folderslug
  143.                 ]);
  144.             }
  145.             $form $this->createForm(BeforeSecureContentsForm::class, $contentS);
  146.             $form->handleRequest($request);
  147.             if ($form->isSubmitted() && $form->isValid()) {
  148.                 //$data = $form->getData();
  149.                 $data $request->request->all();
  150.                 $dataM $data['before_secure_contents_form'];
  151.                 $key $dataM['identifiantKey'];
  152.                 try {
  153.                     $keyDecrypt $this->es->decrypt($contentS->getIdentifiantKey(), $key);
  154.                     if ($keyDecrypt === "mirtillo") {
  155.                         $descriptionDecrypt "";
  156.                         if(!empty($contentS->getDescription())) {
  157.                             $descriptionDecrypt $this->es->decrypt($contentS->getDescription(), $key);
  158.                         }
  159.                         $descriptionContentDecrypt "";
  160.                         if(!empty($contentS->getDescriptionContent())) {
  161.                             $descriptionContentDecrypt $this->es->decrypt($contentS->getDescriptionContent(), $key);
  162.                         }
  163.                         $session->remove($attemptKey); // Réinitialisez le compteur en cas de succès
  164.                         return $this->render('vitrine/'.$themeSelection.'/secure/content.html.twig', [
  165.                             'content' => $contentS,
  166.                             'descriptionContent' => $descriptionContentDecrypt,
  167.                             'description' => $descriptionDecrypt
  168.                         ]);
  169.                     } else {
  170.                         throw new \Exception("Decryption failed");
  171.                     }
  172.                 } catch (\Exception $e) {
  173.                     // En cas d'échec, incrémentez le compteur
  174.                     $attempts++;
  175.                     $session->set($attemptKey$attempts);
  176.                     // Journalisation de l'échec
  177.                     $this->decryptionLogger->warning('Tentative de décryptage échouée', [
  178.                         'user_id' => $this->getUser() ? $this->getUser()->getId() : 'anonyme',
  179.                         'ip' => $request->getClientIp(),
  180.                         'folderslug' => $folderslug,
  181.                         'timestamp' => time(),
  182.                         'tentative' => $attempts
  183.                     ]);
  184.                 }
  185.                 return $this->redirectToRoute('pages_fiche', ['folderslug' => $folderslug]);
  186.             }
  187.             return $this->render('vitrine/'.$themeSelection.'/secure/key_content.html.twig', [
  188.                 'form' => $form->createView(),
  189.                 'content' => $contentS
  190.             ]);
  191.         }
  192.         // Contenu simplifié.
  193.         $content $this->em->getRepository(Contents::class)->getPage($locale,$folderslug);
  194.         if($content) {
  195.             return $this->render('vitrine/'.$themeSelection.'/page_content.html.twig',[
  196.                 'page' => $content
  197.             ]);
  198.         }
  199.         $premiumContent $this->em->getRepository(Articles::class)->findOneBy(['locale' => $locale'folderSlug' => $folderslug'status' => 'ONLINE']);
  200.         if($premiumContent) {
  201.             $user $this->getUser();
  202.             $interactions $this->em->getRepository(Interactions::class)->getThread($premiumContent->getId(),$user);
  203.             $countInteractions $this->em->getRepository(Interactions::class)->countThreads($premiumContent->getId());
  204.             $questions $this->em->getRepository(Interactions::class)->getQuestions($premiumContent->getId());
  205.             $intObj = new Interactions();
  206.             $intObj->setUser($user);
  207.             $intObj->setArticle($premiumContent);
  208.             $intObj->setLocked(false);
  209.             // Interactions
  210.             $formInteractions $this->createForm(InteractionsForm::class,$intObj);
  211.             $formInteractions->handleRequest($request);
  212.             if ($formInteractions->isSubmitted() && $formInteractions->isValid()) {
  213.                 $this->em->persist($intObj);
  214.                 $this->em->flush();
  215.                 return $this->redirectToRoute('pages_fiche',['folderslug' => $folderslug]);
  216.             }
  217.             // Envoyer par mail.
  218.             $formReporting $this->createForm(ReportingEmailForm::class);
  219.             $formReporting->handleRequest($request);
  220.             if ($formReporting->isSubmitted() && $formReporting->isValid()) {
  221.                 $data $request->request->all();
  222.                 dump($data);
  223.                 die;
  224.                 return $this->redirectToRoute('pages_fiche',['folderslug' => $folderslug]);
  225.             }
  226.             return $this->render('vitrine/'.$themeSelection.'/premium/content.html.twig',[
  227.                 'page' => $premiumContent,
  228.                 'fiche' => $premiumContent,
  229.                 'formInteractions' => $formInteractions->createView(),
  230.                 'formReporting' => $formReporting->createView(),
  231.                 'interactions' => $interactions,
  232.                 'countInteractions' => $countInteractions,
  233.                 'questions' => $questions
  234.             ]);
  235.         }
  236.         $page $this->em->getRepository(Pages::class)->getPage($locale,$folderslug);
  237.         if(!$page) {
  238.             return $this->redirectToRoute('homepage');
  239.         }
  240.         $user $this->getUser();
  241.         if($user == null) {
  242.             if($page->getType() == "brouillon") {
  243.                 return $this->redirectToRoute('homepage');
  244.             }
  245.             if(!empty($page->getRedirect())) {
  246.                 return $this->redirect($page->getRedirect());
  247.             }
  248.         } else {
  249.             $grant $this->em->getRepository(Users::class)->userHasRole($user->getId(),"ROLE_SUPER_ADMIN");
  250.             if($grant == "0") {
  251.                 if($page->getType() == "brouillon") {
  252.                     return $this->redirectToRoute('homepage');
  253.                 }
  254.                 if(!empty($page->getRedirect())) {
  255.                     return $this->redirect($page->getRedirect());
  256.                 }
  257.             }
  258.         }
  259.         $blocks $this->em->getRepository(PagesHasBlocks::class)->findBy(['page' => $page'type' => 'prod''startPage' => false],['sequence' => 'ASC']);
  260.         $page->setViews((int)$page->getViews() + 1);
  261.         $this->em->persist($page);
  262.         $this->em->flush();
  263.         return $this->render('vitrine/'.$themeSelection.'/page.html.twig',[
  264.             'page' => $page,
  265.             'blocks' => $blocks
  266.         ]);
  267.     }
  268.     /**
  269.      * 2ème niveau
  270.      * @param Request $request
  271.      * @param $folderslug
  272.      * @param $folderslug2
  273.      * @return mixed
  274.      */
  275.     public function fiche2(Request $request$folderslug$folderslug2)
  276.     {
  277.         $themeSelection $_ENV['THEME_BLOG'];
  278.         $locale $request->getLocale();
  279.         $user $this->getUser();
  280.         $pageArticle $this->em->getRepository(\App\Entity\Articles\Articles::class)->getPage($locale,$folderslug,$folderslug2);
  281.         if($pageArticle !== null) {
  282.             return $this->render('vitrine/'.$themeSelection.'/page_article.html.twig', [
  283.                 'article' => $pageArticle
  284.             ]);
  285.         }
  286.         $content $this->em->getRepository(Contents::class)->getPage($locale,$folderslug,$folderslug2);
  287.         if($content) {
  288.             return $this->render('vitrine/'.$themeSelection.'/page_content.html.twig',[
  289.                 'page' => $content
  290.             ]);
  291.         }
  292.         $premiumContent $this->em->getRepository(Articles::class)->findOneBy(['locale' => $locale'folderSlug' => $folderslug'folderSlug2' => $folderslug2'status' => 'ONLINE']);
  293.         if($premiumContent) {
  294.             $user $this->getUser();
  295.             $interactions $this->em->getRepository(Interactions::class)->getThread($premiumContent->getId(),$user);
  296.             $countInteractions $this->em->getRepository(Interactions::class)->countThreads($premiumContent->getId());
  297.             $questions $this->em->getRepository(Interactions::class)->getQuestions($premiumContent->getId());
  298.             $intObj = new Interactions();
  299.             $intObj->setUser($user);
  300.             $intObj->setArticle($premiumContent);
  301.             $intObj->setLocked(false);
  302.             // Interactions
  303.             $formInteractions $this->createForm(InteractionsForm::class,$intObj);
  304.             $formInteractions->handleRequest($request);
  305.             if ($formInteractions->isSubmitted() && $formInteractions->isValid()) {
  306.                 $this->em->persist($intObj);
  307.                 $this->em->flush();
  308.                 return $this->redirectToRoute('pages_fiche',['folderslug' => $folderslug]);
  309.             }
  310.             return $this->render('vitrine/'.$themeSelection.'/premium/content.html.twig',[
  311.                 'page' => $premiumContent,
  312.                 'fiche' => $premiumContent,
  313.                 'formInteractions' => $formInteractions->createView(),
  314.                 'interactions' => $interactions,
  315.                 'countInteractions' => $countInteractions,
  316.                 'questions' => $questions
  317.             ]);
  318.         }
  319.         $page $this->em->getRepository(Pages::class)->getPage($locale,$folderslug,$folderslug2);
  320.         if(!$page) {
  321.             return $this->redirectToRoute('homepage');
  322.         }
  323.         if($user == null) {
  324.             if($page->getType() == "brouillon") {
  325.                 return $this->redirectToRoute('homepage');
  326.             }
  327.             if(!empty($page->getRedirect())) {
  328.                 return $this->redirect($page->getRedirect());
  329.             }
  330.         } else {
  331.             $grant $this->em->getRepository(Users::class)->userHasRole($user->getId(),"ROLE_SUPER_ADMIN");
  332.             if($grant == "0") {
  333.                 if($page->getType() == "brouillon") {
  334.                     return $this->redirectToRoute('homepage');
  335.                 }
  336.                 if(!empty($page->getRedirect())) {
  337.                     return $this->redirect($page->getRedirect());
  338.                 }
  339.             }
  340.         }
  341.         $blocks $this->em->getRepository(PagesHasBlocks::class)->findBy(['page' => $page'type' => 'prod''startPage' => false],['sequence' => 'ASC']);
  342.         $page->setViews((int)$page->getViews() + 1);
  343.         $this->em->persist($page);
  344.         $this->em->flush();
  345.         return $this->render('vitrine/'.$themeSelection.'/page.html.twig',[
  346.             'page' => $page,
  347.             'blocks' => $blocks
  348.         ]);
  349.     }
  350.     /**
  351.      * 3ème niveau
  352.      * @param Request $request
  353.      * @param $folderslug
  354.      * @param $folderslug2
  355.      * @param $folderslug3
  356.      * @return mixed
  357.      */
  358.     public function fiche3(Request $request$folderslug$folderslug2$folderslug3)
  359.     {
  360.         $themeSelection $_ENV['THEME_BLOG'];
  361.         $locale $request->getLocale();
  362.         $user $this->getUser();
  363.         $pageArticle $this->em->getRepository(\App\Entity\Articles\Articles::class)->getPage($locale,$folderslug,$folderslug2,$folderslug3);
  364.         if($pageArticle !== null) {
  365.             return $this->render('vitrine/'.$themeSelection.'/page_article.html.twig', [
  366.                 'article' => $pageArticle
  367.             ]);
  368.         }
  369.         $content $this->em->getRepository(Contents::class)->getPage($locale,$folderslug,$folderslug2,$folderslug3);
  370.         if($content) {
  371.             return $this->render('vitrine/'.$themeSelection.'/page_content.html.twig',[
  372.                 'page' => $content
  373.             ]);
  374.         }
  375.         $premiumContent $this->em->getRepository(Articles::class)->findOneBy(['locale' => $locale'folderSlug' => $folderslug'folderSlug2' => $folderslug2'folderSlug3' => $folderslug3'status' => 'ONLINE']);
  376.         if($premiumContent) {
  377.             $interactions $this->em->getRepository(Interactions::class)->getThread($premiumContent->getId(),$user);
  378.             $countInteractions $this->em->getRepository(Interactions::class)->countThreads($premiumContent->getId());
  379.             $questions $this->em->getRepository(Interactions::class)->getQuestions($premiumContent->getId());
  380.             $intObj = new Interactions();
  381.             $intObj->setUser($user);
  382.             $intObj->setArticle($premiumContent);
  383.             $intObj->setLocked(false);
  384.             // Interactions
  385.             $formInteractions $this->createForm(InteractionsForm::class,$intObj);
  386.             $formInteractions->handleRequest($request);
  387.             if ($formInteractions->isSubmitted() && $formInteractions->isValid()) {
  388.                 $this->em->persist($intObj);
  389.                 $this->em->flush();
  390.                 return $this->redirectToRoute('pages_fiche',['folderslug' => $folderslug]);
  391.             }
  392.             return $this->render('vitrine/'.$themeSelection.'/premium/content.html.twig',[
  393.                 'page' => $premiumContent,
  394.                 'fiche' => $premiumContent,
  395.                 'formInteractions' => $formInteractions->createView(),
  396.                 'interactions' => $interactions,
  397.                 'countInteractions' => $countInteractions,
  398.                 'questions' => $questions
  399.             ]);
  400.         }
  401.         $page $this->em->getRepository(Pages::class)->getPage($locale,$folderslug,$folderslug2,$folderslug3);
  402.         if(!$page) {
  403.             return $this->redirectToRoute('homepage');
  404.         }
  405.         $user $this->getUser();
  406.         if($user == null) {
  407.             if($page->getType() == "brouillon") {
  408.                 return $this->redirectToRoute('homepage');
  409.             }
  410.             if(!empty($page->getRedirect())) {
  411.                 return $this->redirect($page->getRedirect());
  412.             }
  413.         } else {
  414.             $grant $this->em->getRepository(Users::class)->userHasRole($user->getId(),"ROLE_SUPER_ADMIN");
  415.             if($grant == "0") {
  416.                 if($page->getType() == "brouillon") {
  417.                     return $this->redirectToRoute('homepage');
  418.                 }
  419.                 if(!empty($page->getRedirect())) {
  420.                     return $this->redirect($page->getRedirect());
  421.                 }
  422.             }
  423.         }
  424.         $blocks $this->em->getRepository(PagesHasBlocks::class)->findBy(['page' => $page'type' => 'prod''startPage' => false],['sequence' => 'ASC']);
  425.         $page->setViews((int)$page->getViews() + 1);
  426.         $this->em->persist($page);
  427.         $this->em->flush();
  428.         return $this->render('vitrine/'.$themeSelection.'/page.html.twig',[
  429.             'page' => $page,
  430.             'blocks' => $blocks
  431.         ]);
  432.     }
  433.     /**
  434.      * Redirection vers la page cible de la fiche
  435.      * @param Request $request
  436.      * @param Articles $fiche
  437.      * @param Pages $page
  438.      * @return mixed
  439.      */
  440.     public function redirFiche(Request $requestArticles $fiche)
  441.     {
  442.         $folderslug $fiche->getFolderSlug();
  443.         $folderslug2 $fiche->getFolderSlug2();
  444.         $folderslug3 $fiche->getFolderSlug3();
  445.         if(!empty($folderslug) and !empty($folderslug2) and !empty($folderslug3)) {
  446.             return $this->redirectToRoute('pages_fiche3',['folderslug' => $folderslug'folderslug2' => $folderslug2'folderslug3' => $folderslug3]);
  447.         } elseif(!empty($folderslug) and !empty($folderslug2) and empty($folderslug3)) {
  448.             return $this->redirectToRoute('pages_fiche2',['folderslug' => $folderslug'folderslug2' => $folderslug2]);
  449.         } elseif(!empty($folderslug) and empty($folderslug2) and empty($folderslug3)) {
  450.             return $this->redirectToRoute('pages_fiche',['folderslug' => $folderslug]);
  451.         }
  452.         return $this->redirectToRoute('homepage');
  453.     }
  454.     /**
  455.      * Interactions
  456.      * @param Request $request
  457.      * @param Articles $fiche
  458.      * @param Pages $page
  459.      * @param Interactions $interaction
  460.      * @return mixed
  461.      */
  462.     public function interactions(Request $requestArticles $ficheInteractions $interaction)
  463.     {
  464.         $themeSelection $_ENV['THEME_BLOG'];
  465.         $user $this->getUser();
  466.         $role $this->us->hasRoles($user->getRoles(), "ROLE_SUPER_ADMIN");
  467.         // Vérification si l'utilisateur et privée
  468.         if($interaction->getPersonal() == true) {
  469.             // Vérification si l'utilisateur admin
  470.             if ($role === false) {
  471.                 // Vérification de l'utilisateur du post
  472.                 if($interaction->getUser() != $user) {
  473.                     die('ici');
  474.                     return $this->redirectToRoute('homepage');
  475.                 }
  476.             }
  477.         }
  478.         $interactions $this->em->getRepository(Interactions::class)->findBy(['interaction' => $interaction],['createdAt' => 'ASC']);
  479.         $intObj = new Interactions();
  480.         $intObj->setUser($user);
  481.         $intObj->setArticle($fiche);
  482.         $intObj->setLocked(false);
  483.         $intObj->setPersonal($interaction->getPersonal());
  484.         $intObj->setInteraction($interaction);
  485.         $form $this->createForm(InteractionsSimpleForm::class,$intObj);
  486.         if ($role == true) {
  487.             $form $this->createForm(InteractionsAdminForm::class,$intObj);
  488.         }
  489.         $form->handleRequest($request);
  490.         if ($form->isSubmitted() && $form->isValid()) {
  491.             $this->em->persist($intObj);
  492.             $this->em->flush();
  493.             return $this->redirectToRoute('pages_interactions',['fiche' => $fiche->getId(),'interaction' => $interaction->getId()]);
  494.         }
  495.         return $this->render('vitrine/'.$themeSelection.'/premium/interactions.html.twig',[
  496.             'page' => $fiche,
  497.             'fiche' => $fiche,
  498.             'subject' => $interaction,
  499.             'interactions' => $interactions,
  500.             'formInteractions' => $form->createView(),
  501.         ]);
  502.     }
  503.     /**
  504.      * ADMIN - Modifier une interaction
  505.      * @param Request $request
  506.      * @param Articles $fiche
  507.      * @param Pages $page
  508.      * @param Interactions $interaction
  509.      * @return mixed
  510.      */
  511.     public function editInteraction(Request $requestArticles $ficheInteractions $interaction)
  512.     {
  513.         $themeSelection $_ENV['THEME_BLOG'];
  514.         $user $this->getUser();
  515.         $role $this->us->hasRoles($user->getRoles(), "ROLE_SUPER_ADMIN");
  516.         if ($role != true) {
  517.             return $this->redirectToRoute('homepage');
  518.         }
  519.         $form $this->createForm(InteractionsAdminForm::class,$interaction);
  520.         $form->handleRequest($request);
  521.         if ($form->isSubmitted() && $form->isValid()) {
  522.             $this->em->persist($interaction);
  523.             $this->em->flush();
  524.             return $this->redirectToRoute('pages_interactions',['fiche' => $fiche->getId(),'interaction' => $interaction->getId()]);
  525.         }
  526.         return $this->render('vitrine/'.$themeSelection.'/premium/edit_interaction.html.twig',[
  527.             'page' => $fiche,
  528.             'fiche' => $fiche,
  529.             'interaction' => $interaction,
  530.             'formInteractions' => $form->createView(),
  531.         ]);
  532.     }
  533. }