src/Controller/GIRDirectMailController.php line 92

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\SessionManagerLMDVInterface;
  4. use App\Service\WebServiceLMDV;
  5. use App\Service\WebServiceLMDVInterface;
  6. use Psr\Log\LoggerInterface;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use App\Form\Type\GIRDirectMail\Etape0Type;
  13. use App\Form\Type\GIRDirectMail\Etape1Type;
  14. use App\Form\Type\GIRDirectMail\Etape2Type;
  15. use App\Form\Type\GIRDirectMail\Etape3Type;
  16. use App\Form\Type\GIRDirectMail\ParticipantType;
  17. use App\Entity\GIRDirectMail\Etape0;
  18. use App\Entity\GIRDirectMail\Etape1;
  19. use App\Entity\GIRDirectMail\Etape2;
  20. use App\Entity\GIRDirectMail\Etape3;
  21. use App\Entity\GIRDirectMail\Participant;
  22. use App\Form\Type\GIRDirectMail\ChambreType;
  23. use App\Entity\GIRDirectMail\Chambre;
  24. use App\Exception\LMDVException;
  25. use App\Exception\NonTranslatedException;
  26. use App\Service\SessionManagerLMDV;
  27. use Symfony\Component\HttpFoundation\Response;
  28. use Symfony\Contracts\Translation\TranslatorInterface;
  29. use App\Service\Payment\PaymentInterface;
  30. /**
  31.  * There are at least 4 form steps. In every step we must verify that the $_SESSION information exists
  32.  * otherwise we should return to the FrontController. $_SESSION information must be missing if the user
  33.  * tries to hit a step without having gone through the previous ones or if the PHP garbage collection decides to
  34.  * kill the session. These controls are implemented inside SessionManagerLMDVInterface class.
  35.  *
  36.  * @author jra
  37.  *
  38.  */
  39. class GIRDirectMailController extends AbstractController implements SessionValidController
  40. {
  41.   
  42.   use LMDVControllerTrait;
  43.   
  44.   /**
  45.    * @var \Psr\Log\LoggerInterface
  46.    */
  47.   protected $logger;
  48.   /**
  49.    * @var \Symfony\Contracts\Translation\TranslatorInterface
  50.    */
  51.   protected $translator;
  52.   public function __construct(LoggerInterface $loggerTranslatorInterface $translator)
  53.   {
  54.       $this->logger $logger;
  55.       $this->translator $translator;
  56.   }
  57.   /**
  58.    * @Route("/GIRDirectMail/step0", name="girdirectmail_step0")
  59.    *
  60.    * @param Request $request
  61.    * @param WebServiceLMDVInterface $ws
  62.    * @param SessionManagerLMDVInterface $sm
  63.    * @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
  64.    */
  65.   public function step0(Request $requestWebServiceLMDVInterface $wsSessionManagerLMDVInterface $sm)
  66.   {
  67.       $sm->setEntityNamespace('App\Entity\GIRDirectMail');
  68.       $voyage $sm->getDataFromSession();
  69.       if(! $sm->isValidCustomSessionId($voyage->getSessionId())) {
  70.         //$this->addFlash('error', ['id' => 'error.session.expired']);
  71.         return $this->redirectToRoute('front'$request->query->all());
  72.       }
  73.       // if PDFVoyage is empty, do not show the link
  74.       try {
  75.         $result $ws->getPdfVoyage($voyage);
  76.       }
  77.       catch(\Exception $e) {
  78.         $request->getSession()->set('hasPDFVoyage'FALSE);
  79.       }
  80.       if(empty($result['content'])) {
  81.         $request->getSession()->set('hasPDFVoyage'FALSE);
  82.       }
  83.       else {
  84.         $request->getSession()->set('hasPDFVoyage'TRUE);
  85.       }
  86.       // if PDFVoyage is empty, do not show the link
  87.       // NbrAdultes et NbrEnfants are filled up by default, but we can modify them
  88.       if($voyage->getEtape0()) {
  89.         $etape0 $voyage->getEtape0();
  90.       }
  91.       else {
  92.         $etape0 = new Etape0();
  93.         $etape0->setNbrAdultes($voyage->getAdults());
  94.         $etape0->setNbrEnfants($voyage->getChildren());
  95.       }
  96.       $etape0->setVilleDepart($voyage->getDepartureCity());
  97.       $etape0->setCodeSociete($voyage->getBusinessCode());
  98.       $etape0->setCodeAgent($voyage->getAgentCode());
  99.       $ws->getSalesForceTitleVoyage($voyage);
  100.       $form $this->createForm(Etape0Type::class, $etape0);
  101.       $form->handleRequest($request);
  102.       if ($form->isSubmitted() && $form->isValid()) {
  103.           $etape0 $form->getData();
  104.           // Saves object into session after serializing it.
  105.           $sm->setDataToSession('etape0'$etape0);
  106.           return $this->redirectToRoute('girdirectmail_step1',  $request->query->all());
  107.       }
  108.       return $this->render('lmdv/girdirectmail/step0.html.twig', [
  109.           'form' => $form->createView(),
  110.       ]);
  111.   }
  112.   /**
  113.    * @Route("/GIRDirectMail/step1", name="girdirectmail_step1")
  114.    *
  115.    * @param Request $request
  116.    * @param WebServiceLMDVInterface $ws
  117.    * @param SessionManagerLMDVInterface $sm
  118.    * @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
  119.    */
  120.   public function step1(Request $requestWebServiceLMDVInterface $wsSessionManagerLMDVInterface $sm)
  121.   {
  122.       $sm->setEntityNamespace('App\Entity\GIRDirectMail');
  123.       $voyage $sm->getDataFromSession();
  124.       if(! $voyage->getEtape0()) {
  125.         $this->addFlash('error', ['id' => 'error.session.expired']);
  126.         return $this->redirectToRoute('front'$request->query->all());
  127.       }
  128.       try {
  129.         $volAller $ws->getVolAller($voyage);
  130.         $volRetour $ws->getVolRetour($voyage);
  131.         $miscellaneous $ws->getMiscellaneous($voyage);
  132.         $assurances $ws->getAssurances($voyage);
  133.         $prestations $ws->getPrestations($voyage);
  134.         $ws->getBoxRecap($voyage);
  135.       }
  136.       catch(\Exception $e) {
  137.         $request->getSession()->invalidate();
  138.         return $this->redirectToErrorPage($e);
  139.       }
  140.       $etape1 $voyage->getEtape1() ? $voyage->getEtape1() : new Etape1();
  141.       $maxChambres $voyage->getEtape0()->getNbrAdultes() + $voyage->getEtape0()->getNbrEnfants();
  142.       $nbrChambres $etape1->getNbrChambres() ? $etape1->getNbrChambres() : 1;
  143.       if($nbrChambres $maxChambres) {
  144.         $nbrChambres $maxChambres;
  145.       }
  146.       $etape1->setNbrChambres($nbrChambres);
  147.       $etape1->setMaxChambres($maxChambres);
  148.       $form $this->createForm(Etape1Type::class, $etape1);
  149.       $chambres $etape1->getChambres();
  150.       for($i 1$i <= $maxChambres$i++) {
  151.         if(isset($chambres[$i-1])) {
  152.           $chambre $chambres[$i-1];
  153.           $chambre->refreshChambresInformation($ws$voyage);
  154.         }
  155.         else {
  156.           $chambre = new Chambre($ws$voyage);
  157.         }
  158.         // This is to disable validation for chambres hidden by AJAX
  159.         // Anotations dont work for unmapped fields.
  160.         // it is tricky, it is a dirty way but it works
  161.         $aux = @$request->request->get('etape1')['nbrChambres'];
  162.         if(isset($aux) && is_numeric($aux)) {
  163.           $nbrChambres $aux;
  164.           if($i $nbrChambres) {
  165.             $chambre->setValidated(TRUE);
  166.           }
  167.           else {
  168.             $chambre->setValidated(FALSE);
  169.           }
  170.         }
  171.         $form->add('chambre_' $iChambreType::class, [
  172.             'mapped' => FALSE,
  173.             'data' => $chambre,
  174.         ]);
  175.       }
  176.       $saved_data $etape1->getAssurances() ? $etape1->getAssurances() : [];
  177.       foreach($miscellaneous as $group => $miscellaneous_choices) {
  178.         $default '';
  179.         foreach($miscellaneous_choices as $choice) {
  180.           foreach($choice as $value) {
  181.             if(in_array($value$saved_data)) {
  182.               $default $value;
  183.             }
  184.           }
  185.         }
  186.         $form->add('miscellaneous_' $groupChoiceType::class, [
  187.                'choices' => $miscellaneous_choices,
  188.                'choice_translation_domain' => FALSE,
  189.                'multiple' => FALSE,
  190.                'expanded' => TRUE,
  191.                'mapped' => FALSE,
  192.                'data' => $default
  193.         ]);
  194.       }
  195.       $groups = [];
  196.       foreach($assurances as $group => $assurance_choices) {
  197.         $default = [];
  198.         foreach($assurance_choices as $choice) {
  199.           foreach($choice as $value) {
  200.             if(in_array($value$saved_data)) {
  201.               $default[] = $value;
  202.             }
  203.           }
  204.         }
  205.         $form->add('assurances_' $groupChoiceType::class, [
  206.                'label' => $ws->getAssuranceGroupLabel($group$assurance_choices),
  207.                'label_html' => TRUE,
  208.                'translation_domain' => FALSE,
  209.                'choices' => $assurance_choices,
  210.                'choice_label' => [$ws'getAssuranceDescription'],
  211.                'choice_translation_domain' => FALSE,
  212.                'multiple' => TRUE,
  213.                'expanded' => TRUE,
  214.                'mapped' => FALSE,
  215.                'data' => $default
  216.         ]);
  217.         $groups[] = $group;
  218.       }
  219.       $form->add('hasAssurances'HiddenType::class, [
  220.         'data' => json_encode($groups),
  221.         'mapped' => FALSE
  222.       ]);
  223.       $form->add('prestations'ChoiceType::class, [
  224.              'choices' => $prestations,
  225.              'multiple' => TRUE,
  226.              'expanded' => TRUE
  227.       ]);
  228.       $form->handleRequest($request);
  229.       if ($form->isSubmitted() && $form->isValid()) {
  230.           if($form->get('prev')->isClicked() || $form->get('next')->isClicked()) {
  231.             /** @var \App\Entity\GIRResaWeb\Etape1 $etape1 */
  232.             $etape1 $form->getData();
  233.             $nbrChambres $etape1->getNbrChambres();
  234.             $etape1->setChambres([]);
  235.             for($i 1$i <= $nbrChambres$i++) {
  236.               $chambre $form->get('chambre_' $i)->getData();
  237.               if($chambre->getCategory()) {
  238.                 list($category$code$segmentCode) = explode('#'$chambre->getCategory());
  239.                 $chambre->setDescription($category);
  240.                 $chambre->setCode($code);
  241.                 $chambre->setSegmentCode($segmentCode);
  242.                 $etape1->addChambres($chambre);
  243.               }
  244.             }
  245.             $etape1->setVolAller($volAller);
  246.             $etape1->setVolRetour($volRetour);
  247.             // Retrieval of non-mapped miscellaneous/assurances data, which we must merge and save with etape1->setAssurances()
  248.             $aux = [];
  249.             foreach(array_keys($miscellaneous) as $group) {
  250.               $aux[] = $form->get('miscellaneous_' $group)->getData();
  251.             }
  252.             foreach(array_keys($assurances) as $group) {
  253.               $aux array_merge($aux$form->get('assurances_' $group)->getData());
  254.             }
  255.             $etape1->setAssurances($aux);
  256.             // Saves object into session after serializing it.
  257.             $sm->setDataToSession('etape1'$etape1);
  258.             if($form->get('prev')->isClicked()) {
  259.               return $this->redirectToRoute('girdirectmail_step0'$request->query->all());
  260.             }
  261.             if($form->get('next')->isClicked()) {
  262.               return $this->redirectToRoute('girdirectmail_step2'$request->query->all());
  263.             }
  264.           }
  265.           // AJAX callback come here... We need to get the AJAX updated value 'nbrChambres'
  266.           // Note that we can not add elements to a submitted form !
  267.           if($request->isXmlHttpRequest()) {
  268.             $ajaxData $form->getData();
  269.             $nbrChambres $ajaxData->getNbrChambres();
  270.           }
  271.       }
  272.       return $this->render('lmdv/girdirectmail/step1.html.twig', [
  273.           'form' => $form->createView(),
  274.           'volAller' => $volAller,
  275.           'volRetour' => $volRetour,
  276.           'nbrChambres' => $nbrChambres,
  277.           'maxChambres' => $maxChambres,
  278.           'miscellaneous' => $miscellaneous,
  279.           'assurances' => $assurances
  280.       ]);
  281.   }
  282.   /**
  283.    * @Route("/GIRDirectMail/step2", name="girdirectmail_step2")
  284.    *
  285.    * @param Request $request
  286.    * @param WebServiceLMDVInterface $ws
  287.    * @param SessionManagerLMDVInterface $sm
  288.    * @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
  289.    */
  290.   public function step2(Request $requestWebServiceLMDVInterface $wsSessionManagerLMDVInterface $sm)
  291.   {
  292.       $sm->setEntityNamespace('App\Entity\GIRDirectMail');
  293.       $voyage $sm->getDataFromSession();
  294.       if(! $voyage->getEtape1()) {
  295.         $this->addFlash('error', ['id' => 'error.session.expired']);
  296.         return $this->redirectToRoute('front'$request->query->all());
  297.       }
  298.       $cont 0;
  299.       $total_adults 0;
  300.       $total_children 0;
  301.       $chambres $voyage->getEtape1()->getChambres();
  302.       foreach($chambres as $chambre) {
  303.         $cont $cont $chambre->getNbrAdultes();
  304.         $cont $cont $chambre->getNbrEnfants();
  305.         $total_adults $total_adults $chambre->getNbrAdultes();
  306.         $total_children $total_children $chambre->getNbrEnfants();
  307.       }
  308.       // Validates that the sum of adults/children of all rooms is equal than the total number of adults/children specified in etape0
  309.       if(($voyage->getEtape0()->getNbrAdultes() != $total_adults) || ($voyage->getEtape0()->getNbrEnfants() != $total_children)) {
  310.         $this->addFlash('error', ['id' => "error.form.travellers_mismatch"'parameters' => ['%nbrAdults%' => $voyage->getEtape0()->getNbrAdultes(), '%nbrChildren%' => $voyage->getEtape0()->getNbrEnfants()]]);
  311.         return $this->redirectToRoute('girdirectmail_step1'$request->query->all());
  312.       }
  313.       if($voyage->getEtape2()) {
  314.         $etape2 $voyage->getEtape2();
  315.       }
  316.       else {
  317.         $etape2 = new Etape2();
  318.         try {
  319.           $responsable $ws->getSalesForceResponsable($voyage->getIdOppSF());
  320.           $participants $ws->getSalesForceParticipants($voyage->getIdOppSF());
  321.         }
  322.         catch(\Exception $e) {
  323.           $this->addFlash('error'$e->getMessage());
  324.           return $this->redirectToRoute('girdirectagence_step1'$request->query->all());
  325.         }
  326.         // Prefills up responsable information
  327.         $etape2->setCivilite($responsable['civilite']);
  328.         $etape2->setPrenom($responsable['prenom']);
  329.         $etape2->setNom($responsable['nom']);
  330.         $etape2->setTelephone($responsable['telephone']);
  331.         $etape2->setTelephone2($responsable['telephone2']);
  332.         $etape2->setAdresse($responsable['adresse']);
  333.         $etape2->setCodePostal($responsable['codePostal']);
  334.         $etape2->setVille($responsable['ville']);
  335.         $etape2->setPays($responsable['pays']);
  336.         $etape2->setEmail($responsable['email']);
  337.         $etape2->setSfId($responsable['sfId']);
  338.         $etape2->setCommentaires($responsable['comments']);
  339.         // Prefills up participants information
  340.         foreach($participants as $pax) {
  341.           $p = new Participant();
  342.           $p->setCivilite($pax['civilite']);
  343.           $p->setPrenom($pax['prenom']);
  344.           $p->setNom($pax['nom']);
  345.           $p->setNomJeuneFille($pax['nomJeuneFille']);
  346.           $p->setDateNaissance($pax['dateNaissance']);
  347.           $p->setNationalite($pax['nationalite']);
  348.           $p->setSfId($pax['sfId']);
  349.           $etape2->addParticipants($p);
  350.         }
  351.       }
  352.       $form $this->createForm(Etape2Type::class, $etape2);
  353.       $participants $etape2->getParticipants();
  354.       for($i 1$i <= $cont$i++) {
  355.         $form->add('participant_' $iParticipantType::class, [
  356.             'mapped' => FALSE,
  357.             'data' => isset($participants[$i-1]) ? $participants[$i-1] : new Participant()
  358.         ]);
  359.       }
  360.       $form->handleRequest($request);
  361.       if ($form->isSubmitted() && $form->isValid()) {
  362.           $etape2 $form->getData();
  363.           $etape2->setParticipants([]);
  364.           for($i 1$i <= $cont$i++) {
  365.             $participant $form->get('participant_' $i)->getData();
  366.             $etape2->addParticipants($participant);
  367.           }
  368.           // Saves object into session after serializing it.
  369.           $sm->setDataToSession('etape2'$etape2);
  370.           if($form->get('prev')->isClicked()) {
  371.              return $this->redirectToRoute('girdirectmail_step1'$request->query->all());
  372.           }
  373.           return $this->redirectToRoute('girdirectmail_step3'$request->query->all());
  374.       }
  375.       // On récupère le prix du voyage pour afficher le bandeau recap
  376.       try {
  377.         $ws->getBoxRecap($voyage);
  378.       } catch (\Exception $e) {
  379.         $request->getSession()->invalidate();
  380.         return $this->redirectToErrorPage($e);
  381.       }
  382.       return $this->render('lmdv/girdirectmail/step2.html.twig', [
  383.           'nbrParticipants' => $cont,
  384.           'form' => $form->createView(),
  385.       ]);
  386.   }
  387.   /**
  388.    * @Route("/GIRDirectMail/step3", name="girdirectmail_step3")
  389.    *
  390.    * @param Request $request
  391.    * @param WebServiceLMDVInterface $ws
  392.    * @param SessionManagerLMDVInterface $sm
  393.    * @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
  394.    */
  395.   public function step3(Request $requestWebServiceLMDVInterface $wsSessionManagerLMDVInterface $smPaymentInterface $paymentGateway)
  396.   {
  397.       $sm->setEntityNamespace('App\Entity\GIRDirectMail');
  398.       $voyage $sm->getDataFromSession();
  399.       if(! $voyage->getEtape2()) {
  400.         $this->addFlash('error', ['id' => 'error.session.expired']);
  401.         return $this->redirectToRoute('front'$request->query->all());
  402.       }
  403.       // Validates that the number of adults and children are equal to the initially specified number on etape0
  404.       // using the birthday date of travellers
  405.       $total_adults 0;
  406.       $total_children 0;
  407.       foreach($voyage->getEtape2()->getParticipants() as $participant) {
  408.         if($participant->isChild()) {
  409.           $total_children += 1;
  410.         }
  411.         else {
  412.           $total_adults += 1;
  413.         }
  414.       }
  415.       if(($voyage->getEtape0()->getNbrAdultes() != $total_adults) || ($voyage->getEtape0()->getNbrEnfants() != $total_children)) {
  416.         $this->addFlash('error', ['id' => "error.form.travellers_mismatch"'parameters' => ['%nbrAdults%' => $voyage->getEtape0()->getNbrAdultes(), '%nbrChildren%' => $voyage->getEtape0()->getNbrEnfants()]]);
  417.         return $this->redirectToRoute('girdirectmail_step2'$request->query->all());
  418.       }
  419.       try {
  420.         $price $ws->getTotalAmount($voyage);
  421.         $price_hors_assurances $ws->getTotalAmountHorsAssurances($voyage);
  422.         $accompte $ws->getPayment($voyage);
  423.         $solde $price->substract($accompte);
  424.         $price_details $ws->getPriceDetails($voyage);
  425.         $vols_warning $ws->getVolsWarning($voyage);
  426.       }
  427.       catch(\Exception $e) {
  428.        if($e instanceof NonTranslatedException) {
  429.           $msg $e->getMessage();
  430.           $params $e->getTranslationParameters();
  431.           $errMsg $this->translator->trans($msg$params'messages');
  432.           $this->addFlash('error'$errMsg);
  433.         }
  434.         else {
  435.           $this->addFlash('error'$e->getMessage());
  436.         }
  437.         return $this->redirectToRoute('girdirectmail_step2'$request->query->all());
  438.       }
  439.       $etape3 $voyage->getEtape3() ? $voyage->getEtape3() : new Etape3();
  440.       $form $this->createForm(Etape3Type::class, $etape3);
  441.       $form->handleRequest($request);
  442.       if ($form->isSubmitted() && $form->isValid()) {
  443.           $etape3 $form->getData();
  444.           $etape3->setPriceDetails($price_details);
  445.           $etape3->setTotalPrice($price);
  446.           $etape3->setSolde($solde);
  447.           $etape3->setAccompte($accompte);
  448.           // Saves object into session after serializing it.
  449.           $sm->setDataToSession('etape3'$etape3);
  450.           $voyage $sm->getDataFromSession();
  451.           if($form->get('prev')->isClicked()) {
  452.              return $this->redirectToRoute('girdirectmail_step2'$request->query->all());
  453.           }
  454.           if($form->get('print')->isClicked()) {
  455.              return $this->redirectToRoute('print_girdirectmail'$request->query->all());
  456.           }
  457.           if ($etape3->getTypePayment() == Etape3::PAYMENT_TYPE_ONLINE) {
  458.             try {
  459.               $result $ws->createBooking($voyage);
  460.               $etape3->setNewIdOpp($result['opportunityId']);
  461.               $etape3->setBookingNumber($result['bookingNumber']);
  462.               $sm->setDataToSession('etape3'$etape3);
  463.               // Ticket JIRA-451 : HiPay : Gérer les erreurs HiPay
  464.               try {
  465.                 $external_url $paymentGateway->getPaymentUrl($voyage);
  466.               }
  467.               catch(\Exception $e) {
  468.                 return $this->render('payment/error.html.twig', ['ga' => NULL'bookingID' => substr($voyage->getEtape3()->getBookingNumber(), 3)]);
  469.               }
  470.               // Ticket JIRA-451 : HiPay : Gérer les erreurs HiPay
  471.             }
  472.             catch(\Exception $e) {
  473.               $request->getSession()->set('finished'TRUE);
  474.               return $this->redirectToErrorPage($e);
  475.             }
  476.             return $this->redirect($external_url);
  477.           }
  478.           else {
  479.             try {
  480.               $result $ws->createBooking($voyage);
  481.               $etape3->setBookingNumber($result['bookingNumber']);
  482.               $etape3->setNewIdOpp($result['opportunityId']);
  483.               $sm->setDataToSession('etape3'$etape3);
  484.             }
  485.             catch(\Exception $e) {
  486.               $request->getSession()->set('finished'TRUE);
  487.               return $this->redirectToErrorPage($e);
  488.             }
  489.             return $this->redirectToRoute('girdirectmail_step4'$request->query->all());
  490.           }
  491.       }
  492.       // La date du réglement c'est la date du départ - 45 jours.
  493.       $date_reglement strtotime($voyage->getDepartureDate()) - (45 86400);
  494.       $date_reglement date('d/m/Y'$date_reglement);
  495.       return $this->render('lmdv/girdirectmail/step3.html.twig', [
  496.           'form' => $form->createView(),
  497.           'accompte' => $accompte,
  498.           'prix' => $price,
  499.           'prix_hors_assurances' => $price_hors_assurances,
  500.           'solde' => $solde,
  501.           'price_details' => $price_details,
  502.           'vols_warning' => $vols_warning,
  503.           'dateReglement' => $date_reglement
  504.       ]);
  505.   }
  506.       /**
  507.      * @Route("/GIRDirectMail/step4", name="girdirectmail_step4")
  508.      *
  509.      * @param Request $request
  510.      * @param WebServiceLMDVInterface $ws
  511.      * @param SessionManagerLMDVInterface $sm
  512.      * @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
  513.      */
  514.     public function step4(Request $requestWebServiceLMDVInterface $wsSessionManagerLMDVInterface $sm)
  515.     {
  516.         $sm->setEntityNamespace('App\Entity\GIRDirectMail');
  517.         $voyage $sm->getDataFromSession();
  518.         if(! $voyage->getEtape3()) {
  519.           $this->addFlash('error', ['id' => 'error.session.expired']);
  520.           return $this->redirectToRoute('front'$request->query->all());
  521.         }
  522.         $output $this->render('lmdv/girdirectmail/step4.html.twig', [
  523.             'bookingID' => substr($voyage->getEtape3()->getBookingNumber(), 3),
  524.         ]);
  525.         // Clean up session information if everthing goes well
  526.         // $request->getSession()->invalidate(); - we can no longer do this otherwise the download of the PDFVoyage will not work at last step
  527.         $request->getSession()->set('finished'TRUE);
  528.         return $output;
  529.     }
  530.  
  531. }