src/Controller/FrontController.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Post;
  4. use App\Entity\Role;
  5. use App\Entity\User;
  6. use App\Entity\Media;
  7. use App\Entity\Cabinet;
  8. use App\Entity\Service;
  9. use App\Entity\Category;
  10. use App\Entity\Direction;
  11. use App\Entity\OldMinistre;
  12. use App\Form\RegistrationType;
  13. use App\Form\RegistrationFrontType;
  14. use Doctrine\ORM\EntityManagerInterface;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Doctrine\Common\Persistence\ObjectManager;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  20. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  21. class FrontController extends AbstractController
  22. {
  23.     /**
  24.      * @Route("/old", name="front")
  25.      */
  26.     public function index()
  27.     {
  28.         $repository $this->getDoctrine()->getRepository(Post::class);
  29.         $posts $repository->findPostByCategorieLimit('Informations',5);
  30.         $slides $repository->findPostByCategorieLimit('Slides',3);
  31.         $latest$repository->findBylast();
  32.         //dd($slides);
  33.         return $this->render('front/index.html.twig', [
  34.             'controller_name' => 'FrontController',
  35.             'posts'  =>    $posts,
  36.             'slides'  =>  $slides,
  37.             'latest' => $latest,
  38.         ]);
  39.     }
  40.     /**
  41.      * @Route("/", name="newfront")
  42.      */
  43.     public function indexnew()
  44.     {
  45.         $repository $this->getDoctrine()->getRepository(Post::class);
  46.         $posts $repository->findPostByCategorieLimit('Informations',5);
  47.         $slides $repository->findPostByCategorieLimit('Slides',3);
  48.         $latest$repository->findBylast();
  49.         //dd($slides);
  50.         return $this->render('newwebfront/index.html.twig', [
  51.             'controller_name' => 'FrontController',
  52.             'posts'  =>    $posts,
  53.             'slides'  =>  $slides,
  54.             'latest' => $latest,
  55.         ]);
  56.     }
  57.     /**
  58.      * @Route("/accueil/blog", name="blog")
  59.      */
  60.     public function blog()
  61.     {
  62.         return $this->render('front/blog.html.twig', [
  63.             'controller_name' => 'FrontController',
  64.         ]);
  65.     }
  66.     /**
  67.      * @Route("/accueil/article", name="article")
  68.      */
  69.     public function showarticle()
  70.     {
  71.         return $this->render('front/article.html.twig', [
  72.             'controller_name' => 'FrontController',
  73.         ]);
  74.     }
  75.     /**
  76.      * @Route("/accueil/service", name="service")
  77.      */
  78.     public function showservice()
  79.     {
  80.         $repository $this->getDoctrine()->getRepository(Post::class);
  81.         $services $this->getDoctrine()
  82.                         ->getRepository(Service::class)
  83.                         ->findAll();
  84.         $latest$repository->findBylast();
  85.         return $this->render('front/service.html.twig', [
  86.             'controller_name' => 'FrontController',
  87.             'services'  =>    $services,
  88.             'latest' => $latest,
  89.         ]);
  90.     }
  91.     /**
  92.      * @Route("/accueil/prestation", name="prestation")
  93.      */
  94.     public function showprestation(Request $request)
  95.     {
  96.         $page =$request->query->getInt('page',1);
  97.         $repository $this->getDoctrine()->getRepository(Post::class);
  98.         $services $this->getDoctrine()
  99.                         ->getRepository(Service::class)
  100.                         ->findPaginateAllService($page10);
  101.         $latest$repository->findBylast();
  102.         return $this->render('newwebfront/prestation.html.twig', [
  103.             'controller_name' => 'FrontController',
  104.             'services'  =>    $services,
  105.             'latest' => $latest,
  106.         ]);
  107.     }
  108.     /**
  109.      * @Route("accueil/direction/{sigle}", name="show_direction", methods={"GET"})
  110.      */
  111.     public function directionshow(String $sigle)
  112.     {
  113.         $repository $this->getDoctrine()->getRepository(Direction::class);
  114.         $repository2 $this->getDoctrine()->getRepository(Post::class);
  115.         $repository3 $this->getDoctrine()->getRepository(Cabinet::class);
  116.         $direction $repository->findDirectionBySigle($sigle);
  117.         $latest$repository2->findBylast();
  118.         $membs=$repository3->findAll();
  119.         return $this->render('front/direction.html.twig', [
  120.             'direction' => $direction,
  121.             'latest' => $latest,
  122.             'membs' => $membs,
  123.         ]);
  124.     }
  125.     /**
  126.      * @Route("accueil/newdirection/{sigle}", name="new_show_direction", methods={"GET"})
  127.      */
  128.     public function newdirectionshow(String $sigle)
  129.     {
  130.         $repository $this->getDoctrine()->getRepository(Direction::class);
  131.         $repository2 $this->getDoctrine()->getRepository(Post::class);
  132.         $repository3 $this->getDoctrine()->getRepository(Cabinet::class);
  133.         $direction $repository->findDirectionBySigle($sigle);
  134.         $latest$repository2->findBylast();
  135.         $membs=$repository3->findAll();
  136.         return $this->render('newwebfront/direction.html.twig', [
  137.             'direction' => $direction,
  138.             'latest' => $latest,
  139.             'membs' => $membs,
  140.         ]);
  141.     }
  142.     /**
  143.      * @Route("accueil/ministere/MINISTERE", name="show_ministere")
  144.      */
  145.     public function ministereshow()
  146.     {
  147.         $repository $this->getDoctrine()->getRepository(Direction::class);
  148.         $repository2 $this->getDoctrine()->getRepository(Post::class);
  149.         $repository3 $this->getDoctrine()->getRepository(Cabinet::class);
  150.         $direction $repository->findDirectionBySigle("MINISTERE");
  151.         $latest$repository2->findBylast();
  152.         $membs=$repository3->findAll();
  153.         return $this->render('front/minitere.html.twig', [
  154.             'direction' => $direction,
  155.             'latest' => $latest,
  156.             'membs' => $membs,
  157.         ]);
  158.     }
  159.     /**
  160.      * @Route("/accueil/ministreold", name="ministre")
  161.      */
  162.     public function ministre()
  163.     {
  164.         $repository $this->getDoctrine()->getRepository(Cabinet::class);
  165.         $repository2 $this->getDoctrine()->getRepository(Post::class);
  166.         $membs=$repository->findAll();
  167.         $latest$repository2->findBylast();
  168.         return $this->render('front/ministre.html.twig', [
  169.             'controller_name' => 'FrontController',
  170.             'membs' => $membs,
  171.             'latest' => $latest
  172.         ]);
  173.     }
  174.     /**
  175.      * @Route("/accueil/ministre", name="new_ministre")
  176.      */
  177.     public function ministrenew()
  178.     {
  179.         $repository $this->getDoctrine()->getRepository(Cabinet::class);
  180.         $repository2 $this->getDoctrine()->getRepository(Post::class);
  181.         $membs=$repository->findAll();
  182.         $latest$repository2->findBylast();
  183.         return $this->render('newwebfront/ministre.html.twig', [
  184.             'controller_name' => 'FrontController',
  185.             'membs' => $membs,
  186.             'latest' => $latest
  187.         ]);
  188.     }
  189.     /**
  190.      * @Route("/accueil/documentheque", name="documentheque")
  191.      */
  192.     public function documentheque()
  193.     {
  194.         $repository2 $this->getDoctrine()->getRepository(Post::class);
  195.         $repository $this->getDoctrine()->getRepository(Media::class);
  196.         $latest$repository2->findBylast();
  197.         $docs=$repository->findByOnline();
  198.         return $this->render('front/documentheque.html.twig', [
  199.             'controller_name' => 'FrontController',
  200.             'latest' => $latest,
  201.             'docs' => $docs
  202.         ]);
  203.     }
  204.     /**
  205.      * Permet d'afficher le formulaire d'inscription
  206.      *
  207.      * @Route("/front/register", name="front_register")
  208.      * @return Response
  209.      */
  210.     public function register(Request $requestEntityManagerInterface $managerUserPasswordEncoderInterface $encoder) {
  211.         $user = new User();
  212.         $user->setIsActived(false);
  213.        // $userRole = new Role();
  214.         $userRole=$manager->getRepository('App\Entity\Role')->find(3);
  215.        // $userRole1=$userRole->('ROLE_USERFRONT');
  216. //        $id=$userRole->getId();
  217. //       $id=$manager->getRepository('App\Entity\Role')->findOneBy([
  218. //           'title'=>"ROLE_USERFRONT"
  219. //       ]);
  220. //        dump($userRole);
  221. //        dump($id);die();
  222.        // $manager->persist($userRole);
  223.         $form $this->createForm(RegistrationFrontType::class, $user);
  224.         $form->handleRequest($request);
  225.         if($form->isSubmitted() && $form->isValid()) {
  226.             $hash $encoder->encodePassword($user$user->getHash());
  227.             $user->setHash($hash);
  228.             $user->addUserRole($userRole);
  229.             $manager->persist($user);
  230.             $manager->flush();
  231.             $this->addFlash(
  232.                 'success',
  233.                 "Votre compte a bien été créé ! Vous pouvez maintenant vous connecter !"
  234.             );
  235.             return $this->redirectToRoute('front');
  236.         }
  237.         return $this->render('account/registration.html.twig', [
  238.             'form' => $form->createView()
  239.         ]);
  240.     }
  241.     /**
  242.      * @Route("/adresse", name="contact")
  243.      */
  244.     public function contact()
  245.     {
  246.         return $this->render('contact/contact.html.twig'
  247.         );
  248.     }
  249.     /**
  250.      * @Route("/accueil/anciens-ministres", name="old_ministre")
  251.      */
  252.     public function showoldministre(Request $request)
  253.     {
  254.         $page =$request->query->getInt('page',1);
  255.         $repository $this->getDoctrine()->getRepository(OldMinistre::class);
  256.         $old_ministres $this->getDoctrine()
  257.                         ->getRepository(OldMinistre::class)
  258.                         ->findPaginateAllMinistre($page12);
  259.         //dd($old_ministres);
  260.        
  261.         return $this->render('newwebfront/ancienministre.html.twig', [
  262.             'controller_name' => 'FrontController',
  263.             'old_ministres' => $old_ministres,
  264.         ]);
  265.     }
  266.     /**
  267.      * @Route("/ancien/ministre/{id}", name="show_old_ministre", methods={"GET"})
  268.      */
  269.     public function newpostshow(String $id): Response
  270.     {
  271.         $repository $this->getDoctrine()->getRepository(OldMinistre::class);
  272.         $ministre $repository->findOneBy([
  273.             'id'=>$id
  274.         ]);
  275.         //dd($post);
  276.         return $this->render('newwebfront/presentancienministre.html.twig', [
  277.             'ministre' => $ministre,
  278.         ]);
  279.     }
  280. }