<?php
namespace App\Controller;
use App\Repository\ArticleRepository;
use FontLib\Table\Type\name;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
#[Route('/', name: 'app_home')]
public function index(ArticleRepository $articleRepo): Response
{
if($this->getUser()){
return $this->redirectToRoute('app_lookup');
}
return $this->render('home/index.html.twig', [
'controller_name' => 'HomeController',
'articles' => $articleRepo->findBy(['statut' => true],['id' => 'desc']),
'actif1' => 'active',
'actif2' => '',
'actif3' => '',
'actif4' => '',
'actif5' => '',
]);
}
#[Route('/confirm-your-email-adress/{nom}/{adress}', name:'app_email_confirm_notif')]
public function app_email_confirm_notif($nom, $adress){
return $this->render('home/app_email_confirm_notif.html.twig',['nom' => $nom,'adress' => $adress,
'actif1' => '',
'actif2' => '',
'actif3' => '',
'actif4' => '',
'actif5' => ''
]);
}
#[Route('/app-email-register', name:'app_email_register')]
public function app_email_register(Request $request, MailerInterface $mailer){
$email = $request->query->get('email');
$email = (new TemplatedEmail())
->from(new Address('Godo@consolidis.com',' Orphelia '))
->to($email)
// ->cc('cc@example.com')
//->bcc('bcc@example.com')
//->replyTo('fabien@example.com')
//->priority(Email::PRIORITY_HIGH)
->subject('Créez votre compte dès maintenant pour profiter de tous nos services!')
->htmlTemplate('emails/inscription.html.twig')
// pass variables (name => value) to the template
->context([
'nom' => 'testEmail',
]);
$mailer->send($email);
$this->addFlash('notif','Un mail vous a été transferer pour terminer le processus de votre inscription');
return $this->redirectToRoute('app_home');
}
#[Route('/apropos', name:'app_apropos')]
public function app_apropos(){
return $this->render('home/app_apropos.html.twig',[
'actif1' => '',
'actif2' => 'active',
'actif3' => '',
'actif4' => '',
'actif5' => '',
]);
}
#[Route('/service', name:'app_service')]
public function app_service(){
return $this->render('home/app_service.html.twig',[
'actif1' => '',
'actif2' => '',
'actif3' => 'active',
'actif4' => '',
'actif5' => '',
]);
}
#[Route('/contact', name:'app_contact')]
public function app_contact(){
return $this->render('home/app_contact.html.twig',[
'actif1' => '',
'actif2' => '',
'actif3' => '',
'actif4' => '',
'actif5' => 'active',
]);
}
#[Route('/receive-contact', name:'app_receive_contact')]
public function app_receive_contact(Request $request,MailerInterface $mailer){
$datas = $request->request->all();
$email = (new TemplatedEmail())
->from(new Address('Godo@consolidis.com',' Orphelia '))
->to('tiffa.loic02@gmail.com')
// ->cc('cc@example.com')
//->bcc('bcc@example.com')
//->replyTo('fabien@example.com')
//->priority(Email::PRIORITY_HIGH)
->subject('Prise de contact')
->htmlTemplate('emails/contact.html.twig')
// pass variables (name => value) to the template
->context([
'nom' => $datas['nom'],
'emailAdress' => $datas['email'],
'phone' => $datas['phone'],
'message' => $datas['message']
]);
$mailer->send($email);
$this->addFlash('notif','Votre demande de prise de contact a bien été envoyer. vous serrez contacter sous peux');
return $this->redirectToRoute('app_contact');
}
}