src/Controller/DefaultController.php line 95

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Form\NewsletterSubscriptionType;
  4. use App\Model\Faq;
  5. use App\Service\APIKiwi;
  6. use Exception;
  7. use JMS\Serializer\SerializerInterface;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Contracts\Translation\TranslatorInterface;
  12. class DefaultController extends APIController
  13. {
  14.     /**
  15.      * @Route("/", name="kiwi_homepage")
  16.      * @param Request $request
  17.      * @param APIKiwi $APIKiwi
  18.      * @param TranslatorInterface $translator
  19.      * @param SerializerInterface $serializer
  20.      * @return Response
  21.      * @throws Exception
  22.      */
  23.     public function homepage(Request $requestAPIKiwi $APIKiwiTranslatorInterface $translator,
  24.                              SerializerInterface $serializer)
  25.     {
  26.         $form $this->createForm(NewsletterSubscriptionType::class);
  27.         $form->handleRequest($request);
  28.         if ($form->isSubmitted() && $form->isValid()) {
  29.             $data $form->getData();
  30.             $APIKiwi->postPublicKiwi([
  31.                 'path' => '/public/newsletter-subscription',
  32.                 'data' => [
  33.                     'email' => $data['email'],
  34.                 ]
  35.             ]);
  36.             $this->addFlash('success'$translator->trans('default.newsletter.success'));
  37.         }
  38.         $user $this->getUser();
  39.         return $this->render('default/homepage.html.twig', [
  40.             'user' => $user,
  41.             'newsletterForm' => $form->createView(),
  42.         ]);
  43.     }
  44.     /**
  45.      * @Route("/modalite", name="kiwi_modality")
  46.      */
  47.     public function modality()
  48.     {
  49.         return $this->render('default/modality.html.twig', [
  50.             'user' => $this->getUser(),
  51.         ]);
  52.     }
  53.     /**
  54.      * @Route("/mentions-legales", name="kiwi_mentions_legales")
  55.      */
  56.     public function mentionsLegales()
  57.     {
  58.         return $this->render('default/mentions-legales.html.twig', [
  59.             'user' => $this->getUser(),
  60.         ]);
  61.     }
  62.     /**
  63.      * @Route("/cgu", name="kiwi_cgu")
  64.      */
  65.     public function cgu()
  66.     {
  67.         return $this->render('default/cgu.html.twig', [
  68.             'user' => $this->getUser(),
  69.         ]);
  70.     }
  71.     /**
  72.      * @Route("/donnees-personnelles", name="kiwi_donnees_perso")
  73.      */
  74.     public function donneesPerso()
  75.     {
  76.         return $this->render('default/donnees-perso.html.twig', [
  77.             'user' => $this->getUser(),
  78.         ]);
  79.     }
  80.     /**
  81.      * @Route("/cookies", name="kiwi_cookies")
  82.      */
  83.     public function cookies()
  84.     {
  85.         return $this->render('default/cookies.html.twig', [
  86.             'user' => $this->getUser(),
  87.         ]);
  88.     }
  89.     /**
  90.      * @Route("/faq", name="kiwi_faq")
  91.      */
  92.     public function faq(APIKiwi $APIKiwi)
  93.     {
  94.         $response $APIKiwi->getPublicKiwi('faqs');
  95.         return $this->render('default/faq.html.twig', [
  96.             'faqs' => $this->batchDeserialize(json_decode($response->getContent(), true)['hydra:member'], Faq::class, 'get_faqs'),
  97.         ]);
  98.     }
  99.     /**
  100.      * @Route("/contenus-exclusifs", name="kiwi_cmslist")
  101.      */
  102.     public function cmslist()
  103.     {
  104.         return $this->render('default/cmslist.html.twig', [
  105.             'user' => $this->getUser(),
  106.         ]);
  107.     }
  108.     /**
  109.      * @Route("/contenus-exclusifs/article1", name="kiwi_cmslist_article1")
  110.      */
  111.     public function article1()
  112.     {
  113.         return $this->render('default/articles/article1.html.twig', [
  114.             'user' => $this->getUser(),
  115.         ]);
  116.     }
  117.     /**
  118.      * @Route("/contenus-exclusifs/article2", name="kiwi_cmslist_article2")
  119.      */
  120.     public function article2()
  121.     {
  122.         return $this->render('default/articles/article2.html.twig', [
  123.             'user' => $this->getUser(),
  124.         ]);
  125.     }
  126.     /**
  127.      * @Route("/contenus-exclusifs/article3", name="kiwi_cmslist_article3")
  128.      */
  129.     public function article3()
  130.     {
  131.         return $this->render('default/articles/article3.html.twig', [
  132.             'user' => $this->getUser(),
  133.         ]);
  134.     }
  135.     /**
  136.      * @Route("/contenus-exclusifs/article4", name="kiwi_cmslist_article4")
  137.      */
  138.     public function article4()
  139.     {
  140.         return $this->render('default/articles/article4.html.twig', [
  141.             'user' => $this->getUser(),
  142.         ]);
  143.     }
  144. }