src/Controller/AideController.php line 23

Open in your IDE?
  1. <?php
  2. // src/Controller/AideController.php
  3. namespace App\Controller;
  4. use App\Entity\CategorieArticleAide;
  5. use App\Entity\ArticleAide;
  6. use App\Form\ArticleAideType;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. /**
  11.  * @Route("/{_locale}/help")
  12.  */
  13. class AideController extends AbstractController
  14. {    
  15.     
  16.     /**
  17.      * @Route("/", name="index_aide")
  18.      */
  19.     public function indexAction($_locale '')
  20.     {
  21.         $em $this->getDoctrine()->getManager();
  22.         
  23.         $categorieAides $em->getRepository(CategorieArticleAide::class)
  24.                         ->findByLangue(
  25.                             array( 
  26.                             'langue' => $_locale
  27.                             )
  28.                         );
  29.           return $this->render('entreprise/help.html.twig', [
  30.             'locale' => $_locale,
  31.             'categorieAides' => $categorieAides
  32.         ]);
  33.         
  34.     }
  35.     
  36.     /**
  37.      * @Route("/category/{slug}", name="article_par_categrorie")
  38.      */
  39.     public function articleParCategorieAction(CategorieArticleAide $categorieAide)
  40.     {
  41.         $em $this->getDoctrine()->getManager();
  42.         
  43.         $articleAides $em->getRepository(ArticleAide::class)
  44.                         ->findByCategorie(
  45.                             $categorieAide
  46.                         );
  47.           return $this->render('entreprise/article_help.html.twig', [
  48.             'articleAides' => $articleAides,
  49.             'categorieAide' => $categorieAide
  50.         ]);
  51.         
  52.     }
  53.     
  54.     
  55.     /**
  56.      * @Route("/write-article", name="ecrire_un_article")
  57.      */
  58.     public function ajouterArticleAction()
  59.     {
  60.         /*
  61.         if(!$this->get('security.context')->isGranted('ROLE_AUTEUR'))
  62.         {
  63.             throw $this->createNotFoundException('NAU');
  64.         }
  65.         */
  66.         
  67.         $em $this->getDoctrine()->getManager();
  68.         
  69.         $articleAide = new ArticleAide;
  70.         $form $this->createForm(ArticleAideType::class, $articleAide);
  71.         
  72.         $requestStack $this->get('request_stack');
  73.         $requete $requestStack->getCurrentRequest();
  74.         
  75.         $ok_soumission '';
  76.         $error '';
  77.         
  78.         if('POST' == $requete->getMethod() )
  79.         {
  80.             $form->handleRequest($requete);
  81.             if($form->isValid()){
  82.                 $em->persist($articleAide);
  83.                 $em->flush();
  84.                 
  85.                 $articleAide = new ArticleAide;
  86.                 $form $this->createForm(ArticleAideType::class, $articleAide);
  87.                 $ok_soumission 'Enregistrement effectuĂ©';
  88.             } else{
  89.                 $error 'error s\'est produite, veuillez recommencer';
  90.             }
  91.         }
  92.         
  93.          return $this->render('entreprise/ecrire_article_aide.html.twig', [
  94.             'form' => $form->createView(),
  95.             'ok_soumission' => $ok_soumission,
  96.             'error' => $error
  97.         ]);    
  98.     }
  99.     
  100.     /**
  101.      * @Route("/read-article/{slug}", name="lire_un_article")
  102.      */
  103.     public function lireArticleAction(ArticleAide $article)
  104.     {
  105.         
  106.         return $this->render('entreprise/lire_article_aide.html.twig', [
  107.             'article' => $article
  108.         ]);    
  109.     }
  110.     
  111. }