src/Controller/HomeController.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Client;
  4. use App\Entity\RestaurantCategory;
  5. use App\Entity\RestaurantSubCategory;
  6. use App\Form\ClientActivationType;
  7. use App\Form\RestaurantSubCategoryType;
  8. use App\Repository\ClientRepository;
  9. use App\Repository\LegalRepository;
  10. use App\Repository\RestaurantCategoryRepository;
  11. use App\Repository\RestaurantDishRepository;
  12. use App\Repository\RestaurantMenuRepository;
  13. use App\Repository\RestaurantSubCategoryRepository;
  14. use App\Service\SecureObjectFinder;
  15. use Doctrine\ORM\EntityManagerInterface;
  16. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  17. use Symfony\Component\HttpFoundation\RedirectResponse;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\HttpFoundation\Response;
  20. use Symfony\Component\Routing\Annotation\Route;
  21. use BabyMarkt\DeepL\DeepL;
  22. class HomeController extends AbstractController
  23. {
  24.     /**
  25.      * @Route("/", name="home")
  26.      */
  27.     public function index()
  28.     {
  29.         if ($this->getUser()->getClient()->getActivated() == false){
  30.             return $this->redirectToRoute("activation");
  31.         }
  32.         return $this->render('home/index.html.twig', [
  33.         ]);
  34.     }
  35.     /**
  36.      * Page d'activation du compte client à la première connexion (acceptation des CGU)
  37.      *
  38.      * @Route("/activation", name="activation")
  39.      * @param Request $request
  40.      * @param EntityManagerInterface $manager
  41.      * @return RedirectResponse|Response
  42.      */
  43.     public function activation(Request $requestEntityManagerInterface $managerLegalRepository $repo)
  44.     {
  45.         $client $this->getUser()->getClient();
  46.         $legal $repo->findOneById('1');
  47.         $form $this->createForm(ClientActivationType::class, $client);
  48.         $form->handleRequest($request);
  49.         if($form->isSubmitted() && $form->isValid()){
  50.             $manager->persist($client);
  51.             $manager->flush();
  52.             return $this->redirectToRoute('home');
  53.         }
  54.         return $this->render('home/activation.html.twig', [
  55.             'form' => $form->createView(),
  56.             'legal' => $legal
  57.         ]);
  58.     }
  59. }