src/Controller/HomeController.php line 194

Open in your IDE?
  1. <?php
  2. // src/Controller/HomeController.php
  3. namespace App\Controller;
  4. use App\Repository\ContentRepository;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use App\Repository\PlanningRepository;
  8. use App\Form\PlanningUserType;
  9. use App\Serializer\CountryNormalizer;
  10. use App\Serializer\CountryDenormalizer;
  11. use App\Serializer\StateNormalizer;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  15. use Symfony\Component\Security\Core\Security;
  16. use Symfony\Component\Serializer\Encoder\JsonEncoder;
  17. use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
  18. use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
  19. use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
  20. use Symfony\Component\Serializer\Serializer;
  21. use Doctrine\Common\Annotations\AnnotationReader;
  22. use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
  23. use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
  24. use Symfony\Component\Mailer\MailerInterface;
  25. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  26. class HomeController extends AbstractController
  27. {
  28.     /**
  29.      * @var Security
  30.      */
  31.     private $security;
  32.     public function __construct(Security $security)
  33.     {
  34.         $this->security $security;
  35.     }
  36.     /**
  37.      * @Route("/meeting/confirm/{id}", name="meeting_confirm")
  38.      */
  39.     public function meetingConfirm(int $idContentRepository $contentRepositoryPlanningRepository $planningRepositoryRequest $requestManagerRegistry $doctrineMailerInterface $mailer): Response
  40.     {
  41.         return $this->redirectToRoute('paused');
  42.         $content1 $contentRepository->find(1);
  43.         $content2 $contentRepository->find(2);
  44.         $content3 $contentRepository->find(3);
  45.         $content4 $contentRepository->find(4);
  46.         $content5 $contentRepository->find(5);
  47.         $planning $planningRepository->find($id);
  48.         $formPlanning $this->createForm(PlanningUserType::class, $planning);
  49.         $formPlanning->handleRequest($request);
  50.         if($formPlanning->isSubmitted() && $formPlanning->isValid()) {
  51.             $planningData $formPlanning->getData();
  52.             $planningData->setDateHour($planning->getDateHour());
  53.             $planningData->setDurationText($planning->getDurationText());
  54.             $entityManager $doctrine->getManager();
  55. //            $entityManager->persist($planning);
  56.             $entityManager->flush();
  57.         if($this->getParameter('kernel.environment') != "local") {
  58.                 $email = (new TemplatedEmail())
  59.                     ->from('contact@carolechabanne-psychologue.fr')
  60.                     ->to($planningData->getEmail())
  61.                     ->replyTo('carole.chabanne@outlook.com')
  62.                     ->subject('Confirmation de rendez-vous')
  63.                     ->htmlTemplate('emails\meeting_confirm.html.twig')
  64.             ->context(['planning' => $planningData])
  65.             ->attachFromPath($this->getParameter('kernel.project_dir').'/public/documents/rib_chabanne.pdf');
  66.                 $mailer->send($email);
  67.                 $emailAdmin = (new TemplatedEmail())
  68.                     ->from('contact@carolechabanne-psychologue.fr')
  69.                     ->to('carole.chabanne@outlook.com')
  70.                     ->replyTo('carole.chabanne@outlook.com')
  71.                     ->subject('Nouveau rendez-vous')
  72.                     ->htmlTemplate('emails\meeting_new.html.twig')
  73.                     ->context(['planning' => $planningData]);
  74.                 $mailer->send($emailAdmin);
  75.             }
  76.             $this->addFlash('success''Rendez-vous enregistrĂ©');
  77.             if($this->getParameter('kernel.environment') != "local") {
  78.                 return $this->redirectToRoute('home', ['_fragment' => 'planning']);
  79.             } else {
  80.                 return $this->render('emails\meeting_confirm.html.twig', [
  81.                     'planning' => $planningData
  82.                 ]);
  83.             }
  84.         }
  85.         return $this->render('home/meeting_planning.html.twig', [
  86.             'formPlanning' => $formPlanning->createView(),
  87.             'content1' => $content1,
  88.             'content2' => $content2,
  89.             'content3' => $content3,
  90.             'content4' => $content4,
  91.             'content5' => $content5,
  92.             'planning' => $planning
  93.         ]);
  94.     }
  95.     /**
  96.      * @Route("/meeting/delete/{id}", name="meeting_delete")
  97.      */
  98.     public function meetingDelete(int $idPlanningRepository $planningRepositoryManagerRegistry $doctrineMailerInterface $mailerint $month 0int $year 0): Response
  99.     {
  100.         return $this->redirectToRoute('paused');
  101.         $planning $planningRepository->find($id);
  102.         $planningSvg = clone $planning;
  103.         $planning->setName(null);
  104.         $planning->setFirstname(null);
  105.         $planning->setEmail(null);
  106.         $planning->setPhone(null);
  107.         $entityManager $doctrine->getManager();
  108.         $entityManager->persist($planning);
  109.         $entityManager->flush();
  110.         if($this->getParameter('kernel.environment') != "local") {
  111.             $emailAdmin = (new TemplatedEmail())
  112.                 ->from('contact@carolechabanne-psychologue.fr')
  113.                 ->to('carole.chabanne@outlook.com')
  114.                 ->replyTo('carole.chabanne@outlook.com')
  115.                 ->subject('Rendez-vous annulĂ©')
  116.                 ->htmlTemplate('emails\meeting_cancel.html.twig')
  117.                 ->context(['planning' => $planningSvg]);
  118.             $mailer->send($emailAdmin);
  119.         }
  120.         return $this->redirectToRoute('home', ['_fragment' => 'planning']);
  121.     }
  122.     
  123.     #[Route('/mentions'name'mentions_legales')]
  124.     public function mentions(ContentRepository $contentRepository): Response
  125.     {
  126.         return $this->redirectToRoute('paused');
  127.         $content1 $contentRepository->find(1);
  128.         $content2 $contentRepository->find(2);
  129.         $content3 $contentRepository->find(3);
  130.         $content4 $contentRepository->find(4);
  131.         $content5 $contentRepository->find(5);
  132.         return $this->render('home/mentions.html.twig', [
  133.             'content1' => $content1,
  134.             'content2' => $content2,
  135.             'content3' => $content3,
  136.             'content4' => $content4,
  137.             'content5' => $content5
  138.         ]);
  139.     }
  140.     #[Route('/home'name'home')]
  141.     public function home(ContentRepository $contentRepositoryPlanningRepository $planningRepository): Response
  142.     {
  143.         return $this->redirectToRoute('paused');
  144.         
  145.         $content1 $contentRepository->find(1);
  146.         $content2 $contentRepository->find(2);
  147.         $content3 $contentRepository->find(3);
  148.         $content4 $contentRepository->find(4);
  149.         $content5 $contentRepository->find(5);
  150.         $tabPlannings $planningRepository->findNextFree();
  151.         
  152.         return $this->render('home/index.html.twig', [
  153.             'content1' => $content1,
  154.             'content2' => $content2,
  155.             'content3' => $content3,
  156.             'content4' => $content4,
  157.             'content5' => $content5,
  158.             'tabPlannings' => $tabPlannings
  159.         ]);
  160.     }
  161.     #[Route('/'name'paused')]
  162.     public function paused(): Response
  163.     {
  164.         return $this->render('home/paused.html.twig');
  165.     }
  166. }