src/Controller/Front/FunctionController.php line 186

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.         $data_menu_footer = [];
  79.         $categories $this->getDoctrine()->getRepository(CategoriesProduct::class)->findBy([],['position'=>'ASC']);
  80.         $languages $this->getDoctrine()->getRepository(Language::class)->findActifLang();
  81.         $theme_option $this->getDoctrine()->getRepository(ThemeOptions::class)->findOneBy(['theme'=> $this->theme]);
  82.         $contacts $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  83.         if($contacts){
  84.             foreach ($contacts as $contact) {
  85.                 $contacts_noms[] = ['id'=> $contact->getId(),
  86.                                     'nomContact'=> $contact->translate($_locale)->getNomContact(),
  87.                                    ];
  88.             }
  89.         }
  90.         $Menu $this->getDoctrine()->getRepository(ListeMenu::class)->findOneBy(['type'=>$TypeMenu,'IdSite'=> '1']);
  91.         $social $this->getDoctrine()->getRepository(ReseauSociaux::class)->findBy(['site'=> '1']);
  92.         
  93.         if($Menu){
  94.             $ListMenu $this->getDoctrine()->getRepository(Menu::class)->findMenuActif($Menu->getId());
  95.             $data_menu $buildTree->buildMenu($ListMenu);
  96.         }  
  97.         
  98.         $Menu_footer_top $this->getDoctrine()->getRepository(ListeMenu::class)->findOneBy(['type'=> 'Menu-Footer','IdSite'=> '1']);
  99.         
  100.         if ($Menu_footer_top) {
  101.             $ListMenuFooter $this->getDoctrine()->getRepository(Menu::class)->findMenuActif($Menu_footer_top->getId());
  102.             $data_menu_footer $buildTree->buildMenu($ListMenuFooter);
  103.         }
  104.        
  105.         
  106.         $parametre $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy(['Site'=>'1']);
  107.         $parametreRef $this->getDoctrine()->getRepository(ParametreRef::class)->find(1);
  108.         $secteurs $this->getDoctrine()->getRepository(Secteurs::class)->findBy(['actif'=>true],['position'=>'ASC']);
  109.         
  110.         return $this->render('front/'.$this->theme.'/partials/footer/footer.html.twig',[
  111.             'menus'=> $data_menu,
  112.             'social'=> $social,
  113.             'parametreRef'=> $parametreRef,
  114.             'secteurs'=> $secteurs,
  115.             'languages'=> $languages,
  116.             'categories'=> $categories,
  117.             'parametre'=> $parametre,
  118.             'theme_option'=> $theme_option,
  119.             'contacts'=> $contacts,
  120.             'contactsInfos'=> $contacts_noms,
  121.             'data_menu_footer'=> $data_menu_footer
  122.         ]);
  123.     } 
  124.     public function renderDefaultBloc($alias,RenderDefaultBloc $defaultBloc){
  125.         
  126.         $data_default_bloc null;
  127.         $default_bloc $this->getDoctrine()->getRepository(GroupBloc::class)->findOneBy(['alias'=>$alias]);
  128.         
  129.         if($default_bloc){
  130.             $data_default_bloc $defaultBloc->RenderBloc($default_bloc);
  131.         }
  132.         return $this->render('front/'.$this->theme.'/bloc/render_bloc_default.html.twig',[
  133.             'data_default_bloc'=> $data_default_bloc,
  134.         ]);
  135.     }
  136.     public function renderTextParametrable($id){
  137.         $content_bloc $this->getDoctrine()->getRepository(TextParametrableTranslation::class)->findOneBy(['id'=>$id]);
  138.  
  139.         return $this->render('front/'.$this->theme.'/bloc/texte-parametrable.html.twig',[
  140.             'content_bloc'=> $content_bloc,
  141.         ]);
  142.     }
  143.      public function renderTemplateParametrable($id){
  144.         $content_bloc $this->getDoctrine()->getRepository(TextParametrableTranslation::class)->findOneBy(['id'=>$id]);
  145.  
  146.         return $this->render('front/'.$this->theme.'/bloc/template-parametrable.html.twig',[
  147.             'content_bloc'=> $content_bloc,
  148.         ]);
  149.     }
  150.     public function renderTextCopyright($id){
  151.         $content_bloc $this->getDoctrine()->getRepository(TextParametrableTranslation::class)->findOneBy(['id'=>$id]);
  152.  
  153.         return $this->render('front/'.$this->theme.'/bloc/texte-copyright.html.twig',[
  154.             'content_bloc'=> $content_bloc,
  155.         ]);
  156.     }
  157.     public function renderTitreMenuFooter($id){
  158.         $content_bloc $this->getDoctrine()->getRepository(TextParametrableTranslation::class)->findOneBy(['id'=>$id]);
  159.  
  160.         return $this->render('front/'.$this->theme.'/bloc/titre-menu-footer.html.twig',[
  161.             'content_bloc'=> $content_bloc,
  162.         ]);
  163.     }
  164.     public function renderContacts(){
  165.        
  166.         $param_contact $this->getDoctrine()->getRepository(ParamContact::class)->findOneBy(['id'=>1]);
  167.         $content_bloc $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  168.         return $this->render('front/'.$this->theme.'/bloc/liste-contacts.html.twig',[
  169.             'content_bloc'=> $content_bloc,
  170.             'param_contact'=> $param_contact,
  171.         ]);
  172.     }
  173.     public function renderHorairesPageContact(){
  174.        
  175.         $content_bloc $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  176.         return $this->render('front/'.$this->theme.'/bloc/horaires-contacts.html.twig',[
  177.             'content_bloc'=> $content_bloc,
  178.         ]);
  179.     }
  180.     public function renderMapContact(){
  181.        
  182.         $param_contact $this->getDoctrine()->getRepository(ParamContact::class)->findOneBy(['id'=>1]);
  183.         $contacts $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  184.         return $this->render('front/'.$this->theme.'/bloc/map-contact.html.twig',[
  185.             'contacts'=> $contacts,
  186.             'param_contact'=> $param_contact,
  187.         ]);
  188.     }
  189. }