src/Controller/DefaultController.php line 48

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use \Mailjet\Resources;
  8. use \Mailjet\Client;
  9. class DefaultController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/", name="app_default")
  13.      */
  14.     public function index(): Response
  15.     {
  16.         return $this->render('default/index.html.twig', [
  17.             'controller_name' => 'DefaultController',
  18.         ]);
  19.     }
  20.      /**
  21.      * @Route("/a-propos", name="apropos")
  22.      */
  23.     public function apropos(): Response
  24.     {
  25.         return $this->render('default/apropos.html.twig', [
  26.            
  27.         ]);
  28.     }
  29.      /**
  30.      * @Route("/nos-formations", name="nosformations")
  31.      */
  32.     public function nosformations(): Response
  33.     {
  34.         return $this->render('default/nosformations.html.twig', [
  35.            
  36.         ]);
  37.     }
  38.     /**
  39.      * @Route("/contact", name="contact")
  40.      */
  41.     public function contact(): Response
  42.     {
  43.         return $this->render('default/contact.html.twig', [
  44.            
  45.         ]);
  46.     }
  47.      /**
  48.      * @Route("/mentions-legales", name="mentionslegales")
  49.      */
  50.     public function mentionslegales(): Response
  51.     {
  52.         return $this->render('default/mentionslegales.html.twig', [
  53.            
  54.         ]);
  55.     }
  56.     /**
  57.      * @Route("/politique-de-protection-des-donnees", name="rgpd")
  58.      */
  59.     public function rgpd(): Response
  60.     {
  61.         return $this->render('default/rgpd.html.twig', [
  62.            
  63.         ]);
  64.     }
  65.      /**
  66.      * @Route("/gestion-des-cookies", name="cookies")
  67.      */
  68.     public function cookies(): Response
  69.     {
  70.         return $this->render('default/cookies.html.twig', [
  71.            
  72.         ]);
  73.     }
  74.         /**
  75.      * @Route("/developpeur-web", name="devweb")
  76.      */
  77.     public function devweb(): Response
  78.     {
  79.         return $this->render('default/devweb.html.twig', [
  80.            
  81.         ]);
  82.     }
  83.      /**
  84.      * @Route("/envoiMail", name="envoiMail")
  85.      */
  86.     public function envoiMail(Request $request): Response
  87.     {
  88.         dd($_POST['g-recaptcha-response']);
  89.         if (!empty($_POST['g-recaptcha-response'])){
  90.         $msg $this->renderView(
  91.             // templates/emails/registration.txt.twig
  92.                 'default/email.html.twig',
  93.                 ['nom'=>$_POST['nom'],'prenom'=>$_POST['prenom'],'tel'=>$_POST['tel'],'email'=>$_POST['email'],'commentaire'=>$_POST['commentaire']]
  94.             );
  95.        
  96.             $mj = new \Mailjet\Client('bce86e9943d59ded740db2a28c2f3083','a1db2837eee29a897454015828aba390',true,['version' => 'v3.1']);
  97.             $body = [
  98.                 'Messages' => [
  99.                     [
  100.                         'From' => [
  101.                             'Email' => "noreply@jkc-formations.com",
  102.                             'Name' => "JKC FORMATIONS"
  103.                         ],
  104.                         'To' => [
  105.                             [
  106.                                 'Email' => 'jkcformations@gmail.com',
  107.                                 
  108.                                
  109.                             ]
  110.                         ],
  111.                        
  112.                         
  113.                         'Subject' => 'Demande de contact depuis le site internet',
  114.                         
  115.                         'HTMLPart' => $msg
  116.                     ]
  117.                 ]
  118.             ];
  119.             $response $mj->post(Resources::$Email, ['body' => $body]);
  120.             $response->success();
  121.             $info $response->getData();
  122.         
  123.             return $this->redirectToRoute('contact', ['message'=>'success'], Response::HTTP_SEE_OTHER);
  124.         }
  125.         else
  126.         {
  127.             return $this->redirectToRoute('contact', ['message'=>'erreur'], Response::HTTP_SEE_OTHER);
  128.         }
  129.         
  130.     }
  131. }