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

Open in your IDE?
  1. <?php
  2. namespace App\Controller\General\Template;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  7. use App\Security\TokenAuthenticator;
  8. use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
  9. use App\Service\Servicetext\GeneralServicetext;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use App\Entity\Users\User\User;
  12. use App\Entity\Produit\Service\Typearticle;
  13. use App\Entity\Users\Adminuser\Parametre;
  14. use App\Entity\Users\Adminuser\Parametreitem;
  15. use Doctrine\Common\Collections\ArrayCollection;
  16. use Doctrine\ORM\EntityManagerInterface;
  17. use App\Entity\Produit\Service\Service;
  18. use App\Entity\Produit\Service\Agence;
  19. class MenuController extends AbstractController
  20. {
  21.     private $params;
  22.     private $authenticator;
  23.     private $guardHandler;
  24.     public function __construct(ParameterBagInterface $paramsTokenAuthenticator $authenticatorGuardAuthenticatorHandler $guardHandler)
  25.     {
  26.         $this->params $params;
  27.         $this->authenticator $authenticator;
  28.         $this->guardHandler $guardHandler;
  29.     }
  30.     public function menubare(GeneralServicetext $serviceRequest $request$position)
  31.     {
  32.         $user null;
  33.         $em $this->getDoctrine()->getManager();
  34.         if($this->getUser() == null and isset($_COOKIE["PIDSESSREM"]) and $_COOKIE["PIDSESSREM"] != 'delete')
  35.         {
  36.             $cookies $_COOKIE["PIDSESSREM"];
  37.             $username trim($service->decrypt($cookies$this->params->get('saltcookies')));
  38.             if($service->email($username) || $service->telephone($username))
  39.             {
  40.                 $repository $em->getRepository(User::class);
  41.                 $user $repository->findOneBy(array('username'=>$username));
  42.                 if($user != null)
  43.                 {
  44.                     $response $this->guardHandler->authenticateUserAndHandleSuccess(
  45.                         $user,          // the User object you just created
  46.                         $request,
  47.                         $this->authenticator// authenticator whose onAuthenticationSuccess you want to use
  48.                         'main'          // the name of your firewall in security.yaml
  49.                     );
  50.                 }
  51.             }
  52.         }
  53.         $liste_agence $em->getRepository(Agence::class)
  54.                            ->findAll();
  55.         $type_article $em->getRepository(Typearticle::class)
  56.                          ->myfindAll();
  57.         $aboutContacts $em->getRepository(Parametre::class)
  58.                            ->findOneBy(array('typeParam'=>'contacts'), array('rang'=>'asc'), 1);
  59.         $liste_contacts = new ArrayCollection();
  60.         if($aboutContacts != null)
  61.         {
  62.             $liste_contacts $em->getRepository(Parametreitem::class)
  63.                                  ->findBy(array('parametre'=>$aboutContacts), array('rang'=>'asc'));
  64.         }
  65.         $aboutSocials $em->getRepository(Parametre::class)
  66.                            ->findOneBy(array('typeParam'=>'socialmedia'), array('rang'=>'asc'), 1);
  67.         $social_medias = new ArrayCollection();
  68.         if($aboutSocials != null)
  69.         {
  70.             $social_medias $em->getRepository(Parametreitem::class)
  71.                                  ->findBy(array('parametre'=>$aboutSocials), array('rang'=>'asc'));
  72.         }
  73.         return $this->render($service->getThemeDirectory().'/General/Template/Menu/menubare.html.twig'
  74.         array(
  75.             'position'=>$position
  76.             'type_article'=>$type_article
  77.             'liste_contacts'=>$liste_contacts
  78.             'social_medias'=>$social_medias,
  79.             'liste_agence'=>$liste_agence,
  80.         ));
  81.     }
  82.     
  83.     public function footer(GeneralServicetext $serviceEntityManagerInterface $em$position)
  84.     {
  85.         $aboutplatform $em->getRepository(Parametre::class)
  86.                            ->findOneBy(array('typeParam'=>'aboutplatform'), array('rang'=>'asc'), 1);
  87.         $aboutSocials $em->getRepository(Parametre::class)
  88.                            ->findOneBy(array('typeParam'=>'socialmedia'), array('rang'=>'asc'), 1);
  89.         $social_medias = new ArrayCollection();
  90.         if($aboutSocials != null)
  91.         {
  92.             $social_medias $em->getRepository(Parametreitem::class)
  93.                                  ->findBy(array('parametre'=>$aboutSocials), array('rang'=>'asc'));
  94.         }
  95.         $liste_service $em->getRepository(Service::class)
  96.                             ->findTopServices(5);
  97.         
  98.         $aboutContacts $em->getRepository(Parametre::class)
  99.                             ->findOneBy(array('typeParam'=>'contacts'), array('rang'=>'asc'), 1);
  100.         $liste_contacts = new ArrayCollection();
  101.         if($aboutContacts != null)
  102.         {
  103.             $liste_contacts $em->getRepository(Parametreitem::class)
  104.                                 ->findBy(array('parametre'=>$aboutContacts), array('rang'=>'asc'));
  105.         }
  106.          
  107.         $repository $em->getRepository(Service::class);
  108.         $liste_departement $repository->findServiceTypePagine("departement"18);
  109.         return $this->render($service->getThemeDirectory().'/General/Template/Menu/footer.html.twig'
  110.         array('position'=>$position'aboutplatform'=>$aboutplatform'social_medias'=>$social_medias,
  111.         'liste_service'=>$liste_service'liste_contacts'=>$liste_contacts'liste_departement'=>$liste_departement));
  112.     }
  113.     public function menuleft(GeneralServicetext $service$position)
  114.     {
  115.         return $this->render($service->getThemeDirectory().'/General/Template/Menu/menuleft.html.twig', array('position'=>$position));
  116.     }
  117.     public function newletter(GeneralServicetext $service)
  118.     {
  119.         return $this->render($service->getThemeDirectory().'/General/Template/Menu/newletter.html.twig');
  120.     }
  121. }