<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mime\Email;
use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Routing\Annotation\Route;
use App\Utils\Ticketing;
class HomeController extends AbstractController
{
private $ticketing;
public function __construct(Ticketing $ticketing)
{
$this->ticketing = $ticketing;
}
/**
* @Route("/", name="home")
*/
public function index(Request $request): Response
{
$session = $request->getSession();
if($request->get("ref")){
$session->set('ref', $request->get("ref"));
}
return $this->redirectToRoute('events');
}
/**
* @Route("/terms-and-conditions", name="terms")
*/
public function terms(Request $request): Response
{
return $this->render('terms-conditions.html.twig');
}
/**
* @Route("/contact", name="contact")
*/
public function contact(Request $request, MailerInterface $mailer): Response
{
$session = $request->getSession();
if($request->get("ref")){
$session->set('ref', $request->get("ref"));
}
$status = "";
if($request->get('send-form')){
$name = $request->get('name');
$surname = $request->get('surname');
$email = $request->get('email');
$phone = $request->get('phone');
$text = $request->get('subject');
$mail = (new TemplatedEmail())
->from($this->getParameter('mailer_from'))
->to($this->getParameter('mailer_contact'))
->subject('DBT - Solicitud de contacto')
->htmlTemplate('mail/contact.html.twig')
->context([
'name' => $name,
'surname' => $surname,
'correo' => $email,
'phone' => $phone,
'text' => $text
]);
$mailer->send($mail);
$status = "done";
}
return $this->render('user/contact.html.twig', [
'status' => $status
]);
}
/**
* @Route("/faqs", name="faqs")
*/
public function faqs(Request $request): Response
{
$session = $request->getSession();
if($request->get("ref")){
$session->set('ref', $request->get("ref"));
}
return $this->render('faqs.html.twig');
}
/**
* @Route("/test", name="test")
*/
/*public function test(): Response
{
return $this->render('test.html.twig');
}*/
}