src/Controller/General/Template/MenuController.php line 105

Open in your IDE?
  1. <?php
  2. /*
  3.     (c) Noel Kenfack <noel.kenfack@yahoo.fr>
  4. */
  5. namespace App\Controller\General\Template;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use App\Entity\General\Template\Recherche;
  9. use App\Entity\Users\User\Newsletter;
  10. use App\Entity\Users\User\User;
  11. use App\Form\Users\User\NewsletterType;
  12. use App\Service\Servicetext\GeneralServicetext;
  13. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  14. use App\Entity\Produit\Produit\Categorie;
  15. use App\Entity\Produit\Service\Categorieappli;
  16. use App\Entity\Produit\Service\Application;
  17. use App\Entity\Produit\Service\Service;
  18. use App\Entity\Users\Adminuser\Parametreadmin;
  19. use App\Service\Email\Singleemail;
  20. use App\Security\TokenAuthenticator;
  21. use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
  22. use App\Entity\Produit\Produit\Panier;
  23. use App\Entity\Produit\Service\Recrutement;
  24. use Symfony\Component\HttpFoundation\Request;
  25. class MenuController extends AbstractController
  26. {
  27. private $params;
  28. private $_servicemail;
  29. private $authenticator;
  30. private $guardHandler;
  31. public function __construct(ParameterBagInterface $paramsSingleemail $servicemailTokenAuthenticator $authenticatorGuardAuthenticatorHandler $guardHandler)
  32. {
  33.     $this->params $params;
  34.     $this->_servicemail $servicemail;
  35.     $this->authenticator $authenticator;
  36.     $this->guardHandler $guardHandler;
  37. }
  38. public function menubare(GeneralServicetext $serviceRequest $request$position 'offert')
  39. {
  40.     $em $this->getDoctrine()->getManager();
  41.     if($this->getUser() == null and isset($_COOKIE["PIDSESSREM"]) and $_COOKIE["PIDSESSREM"] != 'delete')
  42.     {
  43.         $cookies $_COOKIE["PIDSESSREM"];
  44.         $username trim($service->decrypt($cookies$this->params->get('saltcookies')));
  45.         
  46.         $repository $em->getRepository(User::class);
  47.         $user $repository->findOneBy(array('username'=>$username));
  48.         
  49.         $user null;
  50.         if($this->getUser() == null and isset($_COOKIE["PIDSESSREM"]) and $_COOKIE["PIDSESSREM"] != 'delete')
  51.         {
  52.             $cookies $_COOKIE["PIDSESSREM"];
  53.             $username trim($service->decrypt($cookies$this->params->get('saltcookies')));
  54.             if($service->email($username) || $service->telephone($username))
  55.             {
  56.                 $repository $em->getRepository(User::class);
  57.                 $user $repository->findOneBy(array('username'=>$username));
  58.                 if($user != null)
  59.                 {
  60.                     $response $this->guardHandler->authenticateUserAndHandleSuccess(
  61.                         $user,          // the User object you just created
  62.                         $request,
  63.                         $this->authenticator// authenticator whose onAuthenticationSuccess you want to use
  64.                         'main'          // the name of your firewall in security.yaml
  65.                     );
  66.                 }
  67.             }
  68.         }
  69.     }
  70.     
  71.     $liste_formation $em->getRepository(Categorie::class)
  72.                              ->myTypeFormation(2);
  73.                              
  74.     $categories_app $em->getRepository(Categorieappli::class)
  75.                           ->myFindAll();
  76.     foreach($liste_formation as $formation)
  77.     {
  78.         $formation->setEm($em);
  79.         foreach($formation->getSouscategories() as $scat)
  80.         {
  81.             $scat->setEm($em);
  82.         }
  83.     }
  84.     $liste_application $em->getRepository(Application::class)
  85.                              ->myFindAll();
  86.     
  87.     $apropos $em->getRepository(Service::class)
  88.                         ->findOneBy(array('typearticle'=>'aproposinstitut'), array('rang'=>'asc'));    
  89.     $article_demarche $em->getRepository(Service::class)
  90.                             ->findBlog(1,3,'demarcheaz');
  91.     $paramlogosm $em->getRepository(Parametreadmin::class)
  92.                        ->findOneBy(array('type'=>'logosm'));
  93.     return $this->render('Theme/General/Template/Menu/menubare.html.twig',
  94.     array('position'=>$position,'categories_app'=>$categories_app'liste_formation'=>$liste_formation,
  95.     'apropos'=>$apropos,'article_demarche'=>$article_demarche,'liste_application'=>$liste_application,
  96.     'paramlogosm'=>$paramlogosm));
  97. }
  98. public function footer($position 'offert'$hideblock='')
  99. {
  100.     $em $this->getDoctrine()->getManager();
  101.     $idcard 0;
  102.     if(isset($_COOKIE["PIDCARD"]) and $_COOKIE["PIDCARD"] != 'empty')
  103.     {
  104.         $idcard $_COOKIE["PIDCARD"];
  105.     }
  106.     
  107.     $liste_prod = new \Doctrine\Common\Collections\ArrayCollection();
  108.     $oldpanier $em->getRepository(Panier::class)
  109.                      ->findOneBy(array('id'=>$idcard,'sousmis'=>0));
  110.     if($oldpanier == null and $this->getUser() != null)
  111.     {
  112.         $oldpanier $em->getRepository(Panier::class)
  113.                         ->findOneBy(array('user'=>$this->getUser(),'sousmis'=>0));
  114.     }
  115.     
  116.     if($oldpanier != null)
  117.     {
  118.         $liste_prod $oldpanier->getProduitpaniers();
  119.     }
  120.     
  121.     $liste_formation $em->getRepository(Categorie::class)
  122.                              ->myTypeFormation(2);
  123.     $apropos $em->getRepository(Service::class)
  124.                         ->findOneBy(array('typearticle'=>'aproposinstitut'), array('rang'=>'asc'));    
  125.     $doc_depliant $em->getRepository(Recrutement::class)
  126.                             ->findBy(array('typedocument'=>'depliant'), array('date'=>'desc'),20);
  127.     $doc_planing $em->getRepository(Recrutement::class)
  128.                             ->findBy(array('typedocument'=>'planing'), array('date'=>'desc'),20);    
  129.     $oldparam5 $em->getRepository(Parametreadmin::class)
  130.                         ->findOneBy(array('type'=>'aproposvideo'));    
  131.     
  132.     $liste_actualite $em->getRepository(Service::class)
  133.                        ->findBy(array('typearticle'=>'actualite','principal'=>1), array('rang'=>'asc'),20);
  134.                        
  135.     return $this->render('Theme/General/Template/Menu/footer.html.twig',
  136.     array('nbproduit'=>count($liste_prod),'position'=>$position,'liste_formation'=>$liste_formation,
  137.     'apropos'=>$apropos,'doc_planing'=>$doc_planing,'doc_depliant'=>$doc_depliant,'hideblock'=>$hideblock,
  138.     'oldparam5'=>$oldparam5,'liste_actualite'=>$liste_actualite));
  139. }
  140. public function menuright($position 'admin')
  141. {
  142.     $em $this->getDoctrine()->getManager();
  143.                        
  144.     return $this->render('Theme/General/Template/Menu/menuright.html.twig',array('position'=>$position));
  145. }
  146. public function menuleft(User $user$position '')
  147. {
  148.     return $this->render('Theme/General/Template/Menu/menuleft.html.twig',
  149.     array('user'=>$user'position'=>$position));
  150. }
  151. public function testinscriptionnewsletter()
  152. {
  153.     $session $this->get('session');
  154.     $envoi $session->get('test_newsletter');
  155.     if($envoi !== 100)
  156.     {
  157.         $newsletter = new Newsletter();
  158.         $form $this->createForm(new NewsletterType$newsletter);
  159.         return $this->render('Theme/General/Template/Menu/testinscriptionnewsletter.html.twig',array('form'=>$form->createView()));
  160.     }
  161.     return new Response(' ');
  162. }
  163. public function stopAlertNewletter()
  164. {
  165.     $session $this->get('session');
  166.     $session->set('test_newsletter',100);
  167.     echo 1;
  168.     exit;
  169. }
  170. }