<?php
namespace App\Controller;
use App\Entity\Documents;
use App\Form\ContactUsFormType;
use Doctrine\Persistence\ManagerRegistry as PersistenceManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Security\MailerController;
use Symfony\Component\HttpFoundation\Cookie;
class DefaultController extends AbstractController
{
private MailerController $mailerController;
public function __construct(MailerController $emailVerifier)
{
$this->mailerController = $emailVerifier;
}
#[Route('/', name: 'homepage')]
public function index(Request $request): Response
{
$form = $this->createForm(ContactUsFormType::class, [
'action' => $this->generateUrl('app_contact_us'),
'method' => 'POST',
]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->mailerController->sendContactUsEmail($request, $form->get('email')->getData(), $form->get('phone')->getData(), $form->get('message')->getData(), $form->get('name')->getData());
return $this->redirectToRoute('app_contact_us');
}
$response = $this->render('default/index.html.twig', [
'form' => $form->createView(),
]);
$cookie = new Cookie(
'mojezprava.cz', // Cookie name.
'cookie value', // Cookie value.
time() + (365 * 24 * 60 * 60) // Expires 1 years.
);
$response->headers->setCookie($cookie);
return $response;
}
#[Route('/contact-us', name: 'app_contact_us')]
public function contactUs(Request $request): Response
{
return $this->render('contact/index.html.twig');
}
#[Route('/faq', name: 'app_faq')]
public function faq(Request $request): Response
{
return $this->render('faq/index.html.twig');
}
#[Route('/special-offer/wedding-day', name: 'app_wedding_day')]
public function weddingDay(Request $request): Response
{
return $this->render('specialOffer/weddingDay.html.twig');
}
#[Route('/special-offer/for-companies', name: 'app_for_companies')]
public function forCompanies(Request $request): Response
{
return $this->render('specialOffer/forCompanies.html.twig');
}
#[Route('/special-offer/for-prom', name: 'app_for_prom')]
public function forProm(Request $request): Response
{
return $this->render('specialOffer/forProm.html.twig');
}
#[Route('/gdpr', name: 'app_general_data_protection_regulation')]
public function generalDataProtectionRegulation(Request $request, PersistenceManagerRegistry $doctrine): Response
{
$entityManager = $doctrine->getManager();
$file = $entityManager->getRepository(Documents::class)->findBy(['name' => 'gdpr'], ['id' => 'DESC'], 1, 0);
return $this->render('documents/generalDataProtectionRegulation.html.twig', [
'file' => $file,
'path' => '/upload/documents/',
]);
}
#[Route('/general-terms-and-conditions', name: 'app_general_terms_and_conditions')]
public function generalTermsAndConditions(Request $request, PersistenceManagerRegistry $doctrine): Response
{
$entityManager = $doctrine->getManager();
$file = $entityManager->getRepository(Documents::class)->findBy(['name' => 'termsAndConditions'], ['id' => 'DESC'], 1, 0);
return $this->render('documents/generalTermsAndConditions.html.twig', [
'file' => $file,
'path' => '/upload/documents/',
]);
}
#[Route('/withdrawal-from-contract', name: 'app_withdrawal_from_the_contract')]
public function withdrawalFromTheContract(Request $request, PersistenceManagerRegistry $doctrine): Response
{
$entityManager = $doctrine->getManager();
$file = $entityManager->getRepository(Documents::class)->findBy(['name' => 'contractWithdrawal'], ['id' => 'DESC'], 1, 0);
return $this->render('documents/withdrawalFromTheContract.html.twig', [
'file' => $file,
'path' => '/upload/documents/',
]);
}
}