src/Controller/Front/HomePageController.php line 63

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Entity\Educational\Chapter;
  4. use App\Entity\Educational\Course;
  5. use App\Entity\Educational\Discipline;
  6. use App\Entity\Educational\Lesson\WorkList;
  7. use App\Entity\Educational\Lesson\WorkListNode;
  8. use App\Entity\Educational\SubChapterDomainVideo;
  9. use App\Entity\Users\Child;
  10. use App\Entity\Users\Contact;
  11. use App\Entity\Users\Parents;
  12. use App\Form\ChildRegistrationOnlyType;
  13. use App\Form\ContactType;
  14. use App\Form\EssaiGratuitParentsRegistrationType;
  15. use App\Form\ParentsRegistrationOnlyType;
  16. use App\Form\ParentsRegistrationType;
  17. use App\Repository\Users\UserRepository;
  18. use App\Service\Mailer\MailerService;
  19. use App\Service\Mailer\SubscriptionMailer;
  20. use App\Service\JWTService;
  21. use App\Service\StripeService;
  22. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  23. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  24. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  25. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  26. use Symfony\Component\HttpFoundation\Cookie;
  27. use Symfony\Component\HttpFoundation\Request;
  28. use Symfony\Component\HttpFoundation\Response;
  29. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  30. use Symfony\Component\Routing\Annotation\Route;
  31. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  32. use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
  33. use SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelperInterface;
  34. class HomePageController extends AbstractController
  35. {
  36.     /**
  37.      * @Route("/upload/transcript/video/html/{wn}/{mode}",name="uplaod-header-file-video")
  38.      */
  39.     public function htmlPdf(Request  $request,$wn null,$mode 1){
  40.         $em $this->getDoctrine()->getManager();
  41.         $wn $em->getRepository(WorkListNode::class)->findOneBySlug($wn);
  42.         if($mode == 1)
  43.         return $this->render('dashboard/educational/pdf/template-pdf-header-video.html.twig', [
  44.             'wn'=>$wn
  45.         ]);
  46.         $all $request->query->all();
  47.         return $this->render('dashboard/educational/pdf/template-pdf-footer-video.html.twig', [
  48.             'wn'=>$wn,
  49.             'all'=>$all
  50.         ]);
  51.     }
  52.     /**
  53.      * @Route("/", name="front")
  54.      */
  55.     public function index(ParameterBagInterface $parameterBag,Request $request): Response
  56.     {
  57.       // $videoJson =  file_get_contents($parameterBag->get('kernel.project_dir').'/public/static/data/video.json');
  58.         //$kumullusVideos = json_decode($videoJson, true);
  59.         return $this->redirectToRoute('app_login');
  60.         return $this->render('front/homePage/index.html.twig', [
  61.             'kumullus_videos' => $kumullusVideos
  62.         ]);
  63.     }
  64.     /**
  65.      * @Route("/nos-coursOP", name="cours-OP" , priority="1")
  66.      */
  67.     public function cours(): Response
  68.     {
  69.         return $this->render('front/homePage/cours.html.twig', [
  70.         ]);
  71.     }
  72.     /**
  73.      * @Route("/nos-profs", name="profs")
  74.      */
  75.     public function profs(): Response
  76.     {
  77.         return $this->redirect("https://www.lesbpnsprofs.com/nos-offres");
  78.     }
  79.     /**
  80.      * @Route("/soutien-scolaire-en-ligne-old", name="offre_old")
  81.      */
  82.     public function offreOld(): Response
  83.     {
  84.         return $this->render('front/homePage/offre.html.twig', [
  85.         ]);
  86.     }
  87.     /**
  88.      * @Route("/soutien-scolaire-en-ligne", name="offre")
  89.      */
  90.     public function offre(Request $requestSubscriptionMailer $subscriptionMailerJWTService $jwt): Response
  91.     {
  92.         return $this->redirect("https://www.lesbonsprofs.com/nos-offres");
  93.         $parents = new Parents();
  94.         $em $this->getDoctrine()->getManager();
  95.         $form $this->createForm(EssaiGratuitParentsRegistrationType::class, $parents);
  96.         $form->handleRequest($request);
  97.         $isSubmit false;
  98.         $session  $request->getSession();
  99.         if ($form->isSubmitted()) {
  100.             if ($form->isValid()) {
  101.                 $session->set('customInfos'$request->request->all());
  102.                 $params $request->request->all();
  103.                 $customInfos $params['essai_gratuit_parents_registration'];
  104.                 $mailParent $customInfos["email"];
  105.                 $firstName  $customInfos["firstname"];
  106.                 if (array_key_exists("isNewsletter",$customInfos) && $customInfos["isNewsletter"] == true){
  107.                     $isNewsletter true;
  108.                 }else{
  109.                     $isNewsletter false;
  110.                 }
  111.                 $registrationProfile $customInfos["registrationProfile"];
  112.                 if(!$firstName || !$mailParent || !$registrationProfile){
  113.                     return $this->redirectToRoute('front');
  114.                 }else{
  115.                 // On génère le JWT de l'utilisateur
  116.                 // On crée le Header
  117.                 $header = [
  118.                     'typ' => 'JWT',
  119.                     'alg' => 'HS256'
  120.                 ];
  121.                 // On crée le Payload
  122.                 $payload = [
  123.                     'parent_mail' => $mailParent,
  124.                     'parent_name' => $firstName,
  125.                     'registration_profile' => $registrationProfile,
  126.                     'is_newsletter' => $isNewsletter,
  127.                 ];
  128.                 // On génère le token
  129.                 $token $jwt->generate($header$payload$this->getParameter('app.jwtsecret')); // .env JWT_SECRET , services.yaml
  130.                 }
  131.                 if(!$token){
  132.                     return $this->redirectToRoute('front');
  133.                 }else{
  134.                     // Replaced :
  135.                     $subscriptionMailer->envoiMailEssaiGratuit($token$mailParent$firstName);      
  136.                     return $this->redirectToRoute('confirmation_essai_gratuit');
  137.                     // new :
  138.                 //echo "merci de visiter : </br>".$this->generateUrl('verify_user', array('token'=>$token), true); exit;
  139.                 }
  140.             }
  141.             $isSubmit true;
  142.         }
  143.         return $this->render('front/homePage/offre-essai-gratuit.html.twig', [
  144.             'form' => $form->createView(),
  145.             'isSubmit' => $isSubmit,
  146.         ]);
  147.     }
  148.     /**
  149.      * @Route("/parent/stage-revisions-vacances", name="stage")
  150.      */
  151.     public function stage(): Response
  152.     {
  153.         return $this->redirect("https://www.lesbonsprofs.com");
  154.         return $this->render('front/homePage/stage.html.twig', [
  155.         ]);
  156.     }
  157.     /**
  158.      * @Route("/parents/revisions-bac-brevet", name="brevet-bac")
  159.      */
  160.     public function brevetBac(): Response
  161.     {
  162.         return $this->render('front/homePage/brevet-bac.html.twig', [
  163.         ]);
  164.     }
  165.     /**
  166.      * @Route("/faq", name="faq")
  167.      */
  168.     public function faq(): Response
  169.     {
  170.         return $this->redirect("https://www.lesbonsprofs.com/faq");
  171.         return $this->render('front/homePage/faq.html.twig', [
  172.         ]);
  173.     }
  174.     /**
  175.      * @Route("/mentions-legales", name="mentions-legales")
  176.      */
  177.     public function mentionsLegales(): Response
  178.     {
  179.         return $this->redirect("https://www.lesbonsprofs.com/mentions-legales-cgu/");
  180.         return $this->render('front/homePage/mentions-legales.html.twig', [
  181.         ]);
  182.     }
  183.     /**
  184.      * @Route("/conditions-generales-d-abonnement",name="cga")
  185.      * @Route("/conditions-generales-d-abonnement-apple",name="cga_apple")
  186.      */
  187.     public function cga()
  188.     {
  189.         return $this->render('front/homePage/cga.html.twig');
  190.     }
  191.     /**
  192.      * @Route("/plan-du-site",name="plan-website")
  193.      */
  194.     public function webMap(){
  195.         return $this->redirect('https://www.lesbonsprofs.com/plan-du-site');
  196.         return $this->render('front/homePage/website.html.twig',[]);
  197.     }
  198.     /**
  199.      * @return Response
  200.      * @Route("/contact", name="contact")
  201.      */
  202.     public function renderContact(Request $requestMailerService $mailerService)
  203.     {
  204.         $contact = new Contact();
  205.         $form $this->createForm(ContactType::class, $contact,  [
  206.             'action' => $this->generateUrl('contact'),
  207.             'method' => 'POST',
  208.         ]);
  209.         $form->handleRequest($request);
  210.         if ( $form->isSubmitted()) {
  211.             if($form->isValid()){
  212.                 $em $this->getDoctrine()->getManager();
  213.                 $mailerService->sendEmailForContact($contact);
  214.                 $em->persist($contact);
  215.                 $em->flush();
  216.                 $this->addFlash('notice',"Votre message a bien été envoyé. Nous allons vous répondre très rapidement.");
  217.             }else{
  218.                 $this->addFlash('notice',"Une erreur est survenue lors de l\'envoie de votre message.");
  219.             }
  220.             return $this->redirectToRoute('front');
  221.         }
  222.         return $this->render("front/homePage/partial/_contact.html.twig", ['form' => $form->createView()]);
  223.     }
  224.     /**
  225.      * @Route("/vie-privee-application",name="privacylaw")
  226.      */
  227.     public function privacylaw(){
  228.         return $this->render('front/homePage/privacy-law.html.twig',[]);
  229.     }
  230.     /**
  231.      * @return Response
  232.      * @Route("/popin")
  233.      */
  234.     public function renderPopinTraining(Request $request)
  235.     {
  236.         $routeName $request->get("route");
  237.         $uri       $request->get("uri");
  238.         if(preg_match("/cours*/i"$uri) || in_array($routeName,['offre','stage','front'])){
  239.       /*      $now = new \DateTime();
  240.             $template = 'popin/popin-advertise-training.html.twig';
  241.             $limit = clone $now;
  242.             $limit->modify('+2 hour');
  243.             $str2  = strtotime($limit->format('Y-m-d H:i:s'));
  244.             $cookies = $request->cookies;
  245.             $response = new Response();
  246.             if ((is_null($cookieTraining = $cookies->get('front_popin')))) {
  247.                 $cookie = new Cookie('front_popin', true, strtotime('now +2 hour'));
  248.                 $response->headers->setCookie($cookie);
  249.                 $response->sendHeaders();
  250.                 return $this->render(
  251.                     $template,
  252.                     []
  253.                 );
  254.             }
  255.       */
  256.         }
  257.         return new Response();
  258.     }
  259. }