<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use \Mailjet\Resources;
use \Mailjet\Client;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="app_default")
*/
public function index(): Response
{
return $this->render('default/index.html.twig', [
'controller_name' => 'DefaultController',
]);
}
/**
* @Route("/a-propos", name="apropos")
*/
public function apropos(): Response
{
return $this->render('default/apropos.html.twig', [
]);
}
/**
* @Route("/nos-formations", name="nosformations")
*/
public function nosformations(): Response
{
return $this->render('default/nosformations.html.twig', [
]);
}
/**
* @Route("/contact", name="contact")
*/
public function contact(): Response
{
return $this->render('default/contact.html.twig', [
]);
}
/**
* @Route("/mentions-legales", name="mentionslegales")
*/
public function mentionslegales(): Response
{
return $this->render('default/mentionslegales.html.twig', [
]);
}
/**
* @Route("/politique-de-protection-des-donnees", name="rgpd")
*/
public function rgpd(): Response
{
return $this->render('default/rgpd.html.twig', [
]);
}
/**
* @Route("/gestion-des-cookies", name="cookies")
*/
public function cookies(): Response
{
return $this->render('default/cookies.html.twig', [
]);
}
/**
* @Route("/developpeur-web", name="devweb")
*/
public function devweb(): Response
{
return $this->render('default/devweb.html.twig', [
]);
}
/**
* @Route("/envoiMail", name="envoiMail")
*/
public function envoiMail(Request $request): Response
{
dd($_POST['g-recaptcha-response']);
if (!empty($_POST['g-recaptcha-response'])){
$msg = $this->renderView(
// templates/emails/registration.txt.twig
'default/email.html.twig',
['nom'=>$_POST['nom'],'prenom'=>$_POST['prenom'],'tel'=>$_POST['tel'],'email'=>$_POST['email'],'commentaire'=>$_POST['commentaire']]
);
$mj = new \Mailjet\Client('bce86e9943d59ded740db2a28c2f3083','a1db2837eee29a897454015828aba390',true,['version' => 'v3.1']);
$body = [
'Messages' => [
[
'From' => [
'Email' => "noreply@jkc-formations.com",
'Name' => "JKC FORMATIONS"
],
'To' => [
[
'Email' => 'jkcformations@gmail.com',
]
],
'Subject' => 'Demande de contact depuis le site internet',
'HTMLPart' => $msg
]
]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success();
$info = $response->getData();
return $this->redirectToRoute('contact', ['message'=>'success'], Response::HTTP_SEE_OTHER);
}
else
{
return $this->redirectToRoute('contact', ['message'=>'erreur'], Response::HTTP_SEE_OTHER);
}
}
}