src/Controller/SiteContactController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Component\HttpFoundation\Response;
  7. // use Symfony\Component\Routing\Annotation\Route;
  8. // use App\Entity\SiteContact;
  9. use App\Form\Type\SiteContactType;
  10. // use App\Entity\SiteNewsletter;
  11. // use App\Entity\SiteShop;
  12. // use App\Entity\Customer\Customer;
  13. // use App\Form\Type\SiteNewsletterType;
  14. // use App\Services\SendInBlueService;
  15. use App\Services\NewsletterService;
  16. use Sylius\Component\Core\Repository\ProductRepositoryInterface;
  17. class SiteContactController extends AbstractController
  18. {
  19.     public function indexAction(
  20.         Request $request
  21.         EntityManagerInterface $entityManager
  22.     ): Response
  23.     {
  24.         // $siteContact = new SiteContact();
  25.         $form $this->createForm(SiteContactType::class);
  26.         $form->handleRequest($request);
  27.         if ($form->isSubmitted() && $form->isValid()){
  28.             $data $form->getData();
  29.             // dump($data);
  30.             $entityManager->persist($data);
  31.             $entityManager->flush();
  32.             $this->addFlash('success''Votre demande est envoyée');
  33.         }
  34.         
  35.         return $this->render('contact.html.twig', [
  36.             'form' => $form->createView()
  37.         ]);
  38.     }
  39.     public function getAccountAction(
  40.         Request $request
  41.         EntityManagerInterface $entityManager,
  42.         NewsletterService $newsletterService
  43.     )
  44.     {
  45.         $form $newsletterService->generateForm(trim($request->get('email')), $entityManagerfalse);
  46.         return $this->render('newsletter/formall.html.twig', [
  47.             'form' => $form->createView()
  48.         ]);
  49.     }
  50.     
  51.     public function newsletterAction(
  52.         Request $request
  53.         EntityManagerInterface $entityManager,
  54.         NewsletterService $newsletterService
  55.     ): Response
  56.     {
  57.         $form $newsletterService->getForm($request$entityManager);
  58.         if($request->getMethod() == 'POST') {
  59.             return $this->redirect($request->getUri());
  60.         }
  61.         
  62.         $formEmail $this->renderView('newsletter/formemail.html.twig', ['form' => $form'hide' => false]);
  63.         $formAll $this->renderView('newsletter/formall.html.twig', ['form' => $form]);
  64.         
  65.         $formView $this->renderView('newsletter/form.html.twig', [
  66.             'formEmail' => $formEmail,
  67.             "formAll"     => $formAll,
  68.             'form' => $form,
  69.             'path'        => 'app_formulairenewsletter'
  70.         ]);
  71.         return $this->render('newsletter.html.twig', [
  72.             "formView" => $formView
  73.         ]);
  74.     }
  75. }