src/Controller/DefaultController.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Coordonnee;
  4. use App\service\SendMailService;
  5. use App\Repository\MenuRepository;
  6. use App\Repository\CoordonneeRepository;
  7. use App\Repository\PublicationRepository;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. class DefaultController extends AbstractController
  13. {
  14.     #[Route('/'name'app_homepage')]
  15.     public function index(): Response
  16.     {
  17.         $menu null;
  18.         return $this->render('frontend.html.twig'compact('menu'));
  19.     }
  20.     #[Route('/m/{slug}'name'app_detail_menu')]
  21.     public function detailMenu(MenuRepository $MenuRepo,PublicationRepository $PubRepo,CoordonneeRepository $coordonneeRepository,$slug null): Response
  22.     {
  23.         $menu $MenuRepo->findBy(["slug" => $slug])[0];
  24.         $publications $PubRepo->findBy(['menu' => $menu->getId()]);
  25.         $coordonnees $coordonneeRepository->findOneBy([],['id' => 'DESC'],1);
  26.         switch ($menu->getId()) {
  27.             case '2':
  28.                 return $this->render('pages/apropos.html.twig'compact('publications','menu'));
  29.                 break;
  30.             case '3':
  31.                 return $this->render('pages/services.html.twig'compact('publications','menu'));
  32.                 break;
  33.             case '4':
  34.                 return $this->render('pages/realisations.html.twig'compact('publications','menu'));
  35.                 break;
  36.             case '5':
  37.                 return $this->render('pages/contact.html.twig'compact('publications','menu','coordonnees'));
  38.                 break;
  39.             
  40.             default:
  41.             return $this->render('frontend.html.twig'compact('menu'));
  42.                 break;
  43.         }
  44.     }
  45.     #[Route('/contact/traitement'name'app_contact')]
  46.     public function contact(Request $requestSendMailService $mail$menu null)
  47.     {
  48.         if($request->isMethod('POST')){
  49.             $form $request->request->all();
  50.             //envoie de mail
  51.             $mail->mailContact($form);
  52.         }
  53.         return $this->render('frontend.html.twig'compact('menu'));
  54.     }
  55.     #[Route('/realisation/{slug}'name'app_detail_realisation')]
  56.     public function detailRealisation(Request $requestPublicationRepository $pr$slug null)
  57.     {
  58.         $p $pr->findBy(["slug" => $slug])[0];
  59.         $aps $pr->findBy([],['id' => 'DESC'],6);
  60.         $menu $p->getMenu();
  61.         
  62.         return $this->render('pages/detail.realisation.html.twig'compact('p','menu','aps'));
  63.     }
  64.     
  65.     #[Route('/Admin2ei'name'app_administration')]
  66.     public function dashboard(): Response
  67.     {
  68.         return $this->render('backend.html.twig');
  69.     }
  70. }