src/Controller/HomeController.php line 39

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Mailer\MailerInterface;
  5. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  6. use Symfony\Component\Mime\Email;
  7. use Symfony\Component\HttpFoundation\{RequestResponse};
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use App\Utils\Ticketing;
  10. class HomeController extends AbstractController
  11. {
  12.     private $ticketing;
  13.     public function __construct(Ticketing $ticketing)
  14.     {
  15.         $this->ticketing $ticketing;
  16.     }
  17.     /**
  18.      * @Route("/", name="home")
  19.      */
  20.     public function index(Request $request): Response
  21.     {
  22.         $session $request->getSession();
  23.         if($request->get("ref")){
  24.             $session->set('ref'$request->get("ref"));
  25.         }
  26.         return $this->redirectToRoute('events');
  27.     }
  28.     /**
  29.      * @Route("/terms-and-conditions", name="terms")
  30.      */
  31.     public function terms(Request $request): Response
  32.     {
  33.         return $this->render('terms-conditions.html.twig');
  34.     }
  35.     /**
  36.      * @Route("/contact", name="contact")
  37.      */
  38.     public function contact(Request $requestMailerInterface $mailer): Response
  39.     {
  40.         $session $request->getSession();
  41.         if($request->get("ref")){
  42.             $session->set('ref'$request->get("ref"));
  43.         }
  44.         $status "";
  45.         
  46.         if($request->get('send-form')){
  47.             $name $request->get('name');
  48.             $surname $request->get('surname');
  49.             $email $request->get('email');
  50.             $phone $request->get('phone');
  51.             $text $request->get('subject');
  52.             $mail = (new TemplatedEmail())
  53.                 ->from($this->getParameter('mailer_from'))
  54.                 ->to($this->getParameter('mailer_contact'))
  55.                 ->subject('DBT - Solicitud de contacto')
  56.                 ->htmlTemplate('mail/contact.html.twig')
  57.                 ->context([
  58.                     'name' => $name,
  59.                     'surname' => $surname,
  60.                     'correo' => $email,
  61.                     'phone' => $phone,
  62.                     'text' => $text
  63.                 ]);
  64.     
  65.                 $mailer->send($mail);
  66.     
  67.                 $status "done";
  68.         }
  69.         
  70.         return $this->render('user/contact.html.twig', [
  71.             'status' => $status
  72.         ]);
  73.     }
  74.     /**
  75.      * @Route("/faqs", name="faqs")
  76.      */
  77.     public function faqs(Request $request): Response
  78.     {
  79.         $session $request->getSession();
  80.         if($request->get("ref")){
  81.             $session->set('ref'$request->get("ref"));
  82.         }
  83.         
  84.         return $this->render('faqs.html.twig');
  85.     }
  86.     /**
  87.      * @Route("/test", name="test")
  88.      */
  89.     /*public function test(): Response
  90.     {
  91.         return $this->render('test.html.twig');
  92.     }*/ 
  93. }