src/Controller/DefaultController.php line 95

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Documents;
  4. use App\Form\ContactUsFormType;
  5. use Doctrine\Persistence\ManagerRegistry as PersistenceManagerRegistry;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use App\Security\MailerController;
  11. use Symfony\Component\HttpFoundation\Cookie;
  12. class DefaultController extends AbstractController
  13. {
  14.     private MailerController $mailerController;
  15.     public function __construct(MailerController $emailVerifier)
  16.     {
  17.         $this->mailerController $emailVerifier;
  18.     }
  19.     #[Route('/'name'homepage')]
  20.     public function index(Request $request): Response
  21.     {
  22.         $form $this->createForm(ContactUsFormType::class, [
  23.             'action' => $this->generateUrl('app_contact_us'),
  24.             'method' => 'POST',
  25.         ]);
  26.         $form->handleRequest($request);
  27.         if ($form->isSubmitted() && $form->isValid()) {
  28.             $this->mailerController->sendContactUsEmail($request$form->get('email')->getData(), $form->get('phone')->getData(), $form->get('message')->getData(), $form->get('name')->getData());
  29.             return $this->redirectToRoute('app_contact_us');
  30.         }
  31.         $response $this->render('default/index.html.twig', [
  32.             'form' => $form->createView(),
  33.         ]);
  34.         $cookie = new Cookie(
  35.             'mojezprava.cz',    // Cookie name.
  36.             'cookie value'// Cookie value.
  37.             time() + (365 24 60 60)  // Expires 1 years.
  38.         );
  39.     
  40.         $response->headers->setCookie($cookie);
  41.         return $response;
  42.     }
  43.     #[Route('/contact-us'name'app_contact_us')]
  44.     public function contactUs(Request $request): Response
  45.     {
  46.         return $this->render('contact/index.html.twig');
  47.     }
  48.     #[Route('/faq'name'app_faq')]
  49.     public function faq(Request $request): Response
  50.     {
  51.         return $this->render('faq/index.html.twig');
  52.     }
  53.     #[Route('/special-offer/wedding-day'name'app_wedding_day')]
  54.     public function weddingDay(Request $request): Response
  55.     {
  56.         return $this->render('specialOffer/weddingDay.html.twig');
  57.     }
  58.     #[Route('/special-offer/for-companies'name'app_for_companies')]
  59.     public function forCompanies(Request $request): Response
  60.     {
  61.         return $this->render('specialOffer/forCompanies.html.twig');
  62.     }
  63.     #[Route('/special-offer/for-prom'name'app_for_prom')]
  64.     public function forProm(Request $request): Response
  65.     {
  66.         return $this->render('specialOffer/forProm.html.twig');
  67.     }
  68.     #[Route('/gdpr'name'app_general_data_protection_regulation')]
  69.     public function generalDataProtectionRegulation(Request $requestPersistenceManagerRegistry $doctrine): Response
  70.     {
  71.         $entityManager $doctrine->getManager();
  72.         $file $entityManager->getRepository(Documents::class)->findBy(['name' => 'gdpr'], ['id' => 'DESC'], 10);
  73.         return $this->render('documents/generalDataProtectionRegulation.html.twig', [
  74.             'file' => $file,
  75.             'path' => '/upload/documents/',
  76.         ]);
  77.     }
  78.     #[Route('/general-terms-and-conditions'name'app_general_terms_and_conditions')]
  79.     public function generalTermsAndConditions(Request $requestPersistenceManagerRegistry $doctrine): Response
  80.     {
  81.         $entityManager $doctrine->getManager();
  82.         $file $entityManager->getRepository(Documents::class)->findBy(['name' => 'termsAndConditions'], ['id' => 'DESC'], 10);
  83.         return $this->render('documents/generalTermsAndConditions.html.twig', [
  84.             'file' => $file,
  85.             'path' => '/upload/documents/',
  86.         ]);
  87.     }
  88.     #[Route('/withdrawal-from-contract'name'app_withdrawal_from_the_contract')]
  89.     public function withdrawalFromTheContract(Request $requestPersistenceManagerRegistry $doctrine): Response
  90.     {
  91.         $entityManager $doctrine->getManager();
  92.         $file $entityManager->getRepository(Documents::class)->findBy(['name' => 'contractWithdrawal'], ['id' => 'DESC'], 10);
  93.         return $this->render('documents/withdrawalFromTheContract.html.twig', [
  94.             'file' => $file,
  95.             'path' => '/upload/documents/',
  96.         ]);
  97.     }
  98. }