src/Controller/Front/FunctionController.php line 196

Open in your IDE?
  1. <?php 
  2. namespace App\Controller\Front;
  3. use App\Entity\Menu;
  4. use App\Entity\Country;
  5. use App\Entity\Language;
  6. use App\Entity\Secteurs;
  7. use App\Entity\GroupBloc;
  8. use App\Entity\ListeMenu;
  9. use App\Service\BuildTree;
  10. use App\Entity\ParametreRef;
  11. use App\Entity\ThemeOptions;
  12. use App\Entity\ParametreSite;
  13. use App\Entity\ProduitOption;
  14. use App\Entity\ReseauSociaux;
  15. use App\Entity\CategoriesProduct;
  16. use App\Entity\Contact;
  17. use App\Entity\ParamContact;
  18. use App\Entity\TextParametrable;
  19. use App\Entity\TextParametrableTranslation;
  20. use App\Service\RenderDefaultBloc;
  21. use Symfony\Component\Filesystem\Filesystem;
  22. use Symfony\Component\HttpFoundation\Request;
  23. use Symfony\Component\HttpFoundation\Response;
  24. use Symfony\Component\Routing\Annotation\Route;
  25. use Symfony\Contracts\HttpClient\HttpClientInterface;
  26. use Symfony\Component\Translation\TranslatorInterface;
  27. use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
  28. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  29. class FunctionController  extends AbstractController
  30. {
  31.     private $theme;
  32.     private $client;
  33.     private $projectDirr;
  34.     
  35.     public function __construct(string $theme,HttpClientInterface $client,string $projectDirr)
  36.     {
  37.         $this->theme $theme;
  38.         $this->client $client;
  39.         $this->projectDirr $projectDirr;
  40.     }
  41.     public function renderMenu(Request $request,BuildTree $buildTree,$className){
  42.         $_locale $request->getLocale();
  43.         $data_menu_right = [];
  44.         $theme_option $this->getDoctrine()->getRepository(ThemeOptions::class)->findOneBy(['theme'=> $this->theme]);
  45.         $languages $this->getDoctrine()->getRepository(Language::class)->findActifLang();
  46.         $Menu_right $this->getDoctrine()->getRepository(ListeMenu::class)->findOneBy(['type'=>'Header-right','IdSite'=> '1']);
  47.         
  48.         $contacts $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  49.         if($contacts){
  50.             foreach ($contacts as $contact) {
  51.                 $contacts_noms[] = ['id'=> $contact->getId(),
  52.                                     'nomContact'=> $contact->translate($_locale)->getNomContact(),
  53.                                    ];
  54.             }
  55.         }
  56.         
  57.         $social $this->getDoctrine()->getRepository(ReseauSociaux::class)->findBy(['site'=> '1']);
  58.         
  59.         if($Menu_right){
  60.             $ListMenu_rigth $this->getDoctrine()->getRepository(Menu::class)->findMenuActif($Menu_right->getId());
  61.             $data_menu_right $buildTree->buildMenu($ListMenu_rigth);
  62.         }
  63.       
  64.         return $this->render('front/'.$this->theme.'/partials/header/header.html.twig',[
  65.             'menu_right'=> $data_menu_right,
  66.             'languages'=> $languages,
  67.             'className'=> $className,
  68.             'theme_option'=> $theme_option,
  69.             'contacts'=> $contacts,
  70.             'contactsInfos'=> $contacts_noms,
  71.             'social'=> $social,
  72.             'menuDetails' => $ListMenu_rigth,
  73.         ]);
  74.     } 
  75.     public function renderFooter(Request $request,$TypeMenu,BuildTree $buildTree){
  76.         $_locale $request->getLocale(); 
  77.         $data_menu = [];
  78.         $categories $this->getDoctrine()->getRepository(CategoriesProduct::class)->findBy([],['position'=>'ASC']);
  79.         $languages $this->getDoctrine()->getRepository(Language::class)->findActifLang();
  80.         $theme_option $this->getDoctrine()->getRepository(ThemeOptions::class)->findOneBy(['theme'=> $this->theme]);
  81.         $contacts $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  82.         if($contacts){
  83.             foreach ($contacts as $contact) {
  84.                 $contacts_noms[] = ['id'=> $contact->getId(),
  85.                                     'nomContact'=> $contact->translate($_locale)->getNomContact(),
  86.                                    ];
  87.             }
  88.         }
  89.         $Menu $this->getDoctrine()->getRepository(ListeMenu::class)->findOneBy(['type'=>$TypeMenu,'IdSite'=> '1']);
  90.         $social $this->getDoctrine()->getRepository(ReseauSociaux::class)->findBy(['site'=> '1']);
  91.         
  92.         if($Menu){
  93.             $ListMenu $this->getDoctrine()->getRepository(Menu::class)->findMenuActif($Menu->getId());
  94.             $data_menu $buildTree->buildMenu($ListMenu);
  95.         }   
  96.         
  97.         $parametre $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy(['Site'=>'1']);
  98.         $parametreRef $this->getDoctrine()->getRepository(ParametreRef::class)->find(1);
  99.         $secteurs $this->getDoctrine()->getRepository(Secteurs::class)->findBy(['actif'=>true],['position'=>'ASC']);
  100.         
  101.         return $this->render('front/'.$this->theme.'/partials/footer/footer.html.twig',[
  102.             'menus'=> $data_menu,
  103.             'social'=> $social,
  104.             'parametreRef'=> $parametreRef,
  105.             'secteurs'=> $secteurs,
  106.             'languages'=> $languages,
  107.             'categories'=> $categories,
  108.             'parametre'=> $parametre,
  109.             'theme_option'=> $theme_option,
  110.             'contacts'=> $contacts,
  111.             'contactsInfos'=> $contacts_noms,
  112.         ]);
  113.     } 
  114.     public function renderDefaultBloc($alias,RenderDefaultBloc $defaultBloc){
  115.         
  116.         $data_default_bloc null;
  117.         $default_bloc $this->getDoctrine()->getRepository(GroupBloc::class)->findOneBy(['alias'=>$alias]);
  118.         
  119.         if($default_bloc){
  120.             $data_default_bloc $defaultBloc->RenderBloc($default_bloc);
  121.         }
  122.         return $this->render('front/'.$this->theme.'/bloc/render_bloc_default.html.twig',[
  123.             'data_default_bloc'=> $data_default_bloc,
  124.         ]);
  125.     }
  126.     public function renderTextParametrable($id){
  127.         $content_bloc $this->getDoctrine()->getRepository(TextParametrableTranslation::class)->findOneBy(['id'=>$id]);
  128.  
  129.         return $this->render('front/'.$this->theme.'/bloc/texte-parametrable.html.twig',[
  130.             'content_bloc'=> $content_bloc,
  131.         ]);
  132.     }
  133.      public function renderTemplateParametrable($id){
  134.         $content_bloc $this->getDoctrine()->getRepository(TextParametrableTranslation::class)->findOneBy(['id'=>$id]);
  135.  
  136.         return $this->render('front/'.$this->theme.'/bloc/template-parametrable.html.twig',[
  137.             'content_bloc'=> $content_bloc,
  138.         ]);
  139.     }
  140.     public function renderTextCopyright($id){
  141.         $content_bloc $this->getDoctrine()->getRepository(TextParametrableTranslation::class)->findOneBy(['id'=>$id]);
  142.  
  143.         return $this->render('front/'.$this->theme.'/bloc/texte-copyright.html.twig',[
  144.             'content_bloc'=> $content_bloc,
  145.         ]);
  146.     }
  147.     public function renderTitreMenuFooter($id){
  148.         $content_bloc $this->getDoctrine()->getRepository(TextParametrableTranslation::class)->findOneBy(['id'=>$id]);
  149.  
  150.         return $this->render('front/'.$this->theme.'/bloc/titre-menu-footer.html.twig',[
  151.             'content_bloc'=> $content_bloc,
  152.         ]);
  153.     }
  154.     public function renderContacts(){
  155.        
  156.         $param_contact $this->getDoctrine()->getRepository(ParamContact::class)->findOneBy(['id'=>1]);
  157.         $content_bloc $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  158.         return $this->render('front/'.$this->theme.'/bloc/liste-contacts.html.twig',[
  159.             'content_bloc'=> $content_bloc,
  160.             'param_contact'=> $param_contact,
  161.         ]);
  162.     }
  163.     public function renderHorairesPageContact(){
  164.        
  165.         $content_bloc $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  166.         return $this->render('front/'.$this->theme.'/bloc/horaires-contacts.html.twig',[
  167.             'content_bloc'=> $content_bloc,
  168.         ]);
  169.     }
  170.     public function renderMapContact(){
  171.        
  172.         $param_contact $this->getDoctrine()->getRepository(ParamContact::class)->findOneBy(['id'=>1]);
  173.         $contacts $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  174.         return $this->render('front/'.$this->theme.'/bloc/map-contact.html.twig',[
  175.             'contacts'=> $contacts,
  176.             'param_contact'=> $param_contact,
  177.         ]);
  178.     }
  179. }