src/Controller/FrontEnd/FeatureController.php line 127

Open in your IDE?
  1. <?php
  2. namespace App\Controller\FrontEnd;
  3. use App\Entity\Menu;
  4. use App\Entity\Forms;
  5. use App\Entity\Contact;
  6. use App\Entity\Country;
  7. use App\Entity\Language;
  8. use App\Entity\Secteurs;
  9. use App\Entity\FormsData;
  10. use App\Entity\GroupBloc;
  11. use App\Entity\ListeMenu;
  12. use App\Entity\FormsFields;
  13. use App\Entity\ParamContact;
  14. use App\Entity\ParametreRef;
  15. use App\Entity\ThemeOptions;
  16. use App\Entity\ParametreSite;
  17. use App\Entity\ProduitOption;
  18. use App\Entity\ReseauSociaux;
  19. use App\Entity\TelephonesClick;
  20. use App\Entity\TextParametrable;
  21. use App\Service\NestedTreeStructure;
  22. use Doctrine\ORM\EntityManagerInterface;
  23. use App\Entity\TextParametrableTranslation;
  24. use Symfony\Component\Filesystem\Filesystem;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use Symfony\Component\HttpFoundation\Response;
  27. use Symfony\Component\Routing\Annotation\Route;
  28. use Symfony\Component\HttpFoundation\JsonResponse;
  29. use Symfony\Contracts\HttpClient\HttpClientInterface;
  30. use Symfony\Component\Translation\TranslatorInterface;
  31. use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
  32. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  33. class FeatureController extends AbstractController
  34. {
  35. private $theme;
  36. private $client;
  37. private $projectDirr;
  38. public function __construct(string $theme,HttpClientInterface $client,string $projectDirr)
  39. {
  40. $this->theme = $theme;
  41. $this->client = $client;
  42. $this->projectDirr = $projectDirr;
  43. }
  44. /**
  45. * @Route("lang/{language}", name="setlocale_langauge")
  46. */
  47. public function setLocaleLangAction(Request $request,$language = null)
  48. {
  49. if($language != null)
  50. {
  51. $request->getSession()->set('_locale', $language);
  52. }
  53. return $this->redirectToRoute('index_page_home',['_locale'=> $language]);
  54. }
  55. /**
  56. * @Route("/track-phone-click", methods={"POST"}, name="track_phone_click", condition="request.isXmlHttpRequest()")
  57. */
  58. public function trackPhoneClick(Request $request,EntityManagerInterface $em)
  59. {
  60. if ($request->isXmlHttpRequest()) {
  61. $_locale = $request->getLocale();
  62. $parametre = $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy([],['id'=> 'ASC']);
  63. if($parametre){
  64. $nb_click = $parametre->getNbClickTel() != null ?$parametre->getNbClickTel():'0';
  65. $parametre->setNbClickTel($nb_click + 1);
  66. $em->flush();
  67. }
  68. return new JsonResponse(['message'=> 'Phone click saved successfully']);
  69. }
  70. }
  71. public function renderMenu(Request $request,NestedTreeStructure $buildTree,$className= ''){
  72. $_locale = $request->getLocale();
  73. $data_menu_right = [];
  74. $ListMenu_rigth = [];
  75. $theme_option = $this->getDoctrine()->getRepository(ThemeOptions::class)->findOneBy(['theme'=> $this->theme]);
  76. $languages = $this->getDoctrine()->getRepository(Language::class)->findActifLang();
  77. $Menu_right = $this->getDoctrine()->getRepository(ListeMenu::class)->findOneBy(['type'=>'Header-right','IdSite'=> '1']);
  78. $contacts = $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  79. $contacts_noms = [];
  80. if($contacts){
  81. foreach ($contacts as $contact) {
  82. $contacts_noms[] = ['id'=> $contact->getId(),
  83. 'nomContact'=> $contact->translate($_locale)->getNomContact(),
  84. ];
  85. }
  86. }
  87. $socials = $this->getDoctrine()->getRepository(ReseauSociaux::class)->findAll();
  88. if($Menu_right){
  89. $ListMenu_rigth = $this->getDoctrine()->getRepository(Menu::class)->findMenuActif($Menu_right->getId());
  90. $data_menu_right = $buildTree->buildMenu($ListMenu_rigth);
  91. }
  92. return $this->render('theme/'.$this->theme.'/partials/_header.html.twig',[
  93. 'menu_right'=> $data_menu_right,
  94. 'languages'=> $languages,
  95. 'className'=> $className,
  96. 'theme_option'=> $theme_option,
  97. 'contacts'=> $contacts,
  98. 'contactsInfos'=> $contacts_noms,
  99. 'socials'=> $socials,
  100. 'menuDetails' => $ListMenu_rigth,
  101. 'locale'=> $_locale
  102. ]);
  103. }
  104. public function renderFooter(Request $request,$TypeMenu,NestedTreeStructure $buildTree){
  105. $_locale = $request->getLocale();
  106. $menusFooter = null;
  107. $menusFooterBas = null;
  108. $contacts = $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  109. $parametre = $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy([],['id'=> 'ASC']);
  110. $data_menu_footer = $this->getDoctrine()->getRepository(ListeMenu::class)->findOneBy(['type'=> 'Footer']);
  111. if ($data_menu_footer) {
  112. $menu_items = $this->getDoctrine()->getRepository(Menu::class)->findMenuActif($data_menu_footer->getId());
  113. $menusFooterBas = $buildTree->buildMenu($menu_items);
  114. };
  115. $data_menu_footer_bas = $this->getDoctrine()->getRepository(ListeMenu::class)->findOneBy(['type'=> 'Menu-Footer']);
  116. if ($data_menu_footer_bas) {
  117. $menu_items = $this->getDoctrine()->getRepository(Menu::class)->findMenuActif($data_menu_footer_bas->getId());
  118. $menusFooter = $buildTree->buildMenu($menu_items);
  119. }
  120. $socials = $this->getDoctrine()->getRepository(ReseauSociaux::class)->findAll();
  121. return $this->render('theme/'.$this->theme.'/partials/_footer.html.twig',[
  122. 'contacts'=> $contacts,
  123. 'parametre'=> $parametre,
  124. 'menusFooter'=> $menusFooter,
  125. 'menusFooterBas'=> $menusFooterBas,
  126. 'socials'=> $socials
  127. ]);
  128. }
  129. public function displayContactsList(){
  130. $param_contact = $this->getDoctrine()->getRepository(ParamContact::class)->findOneBy(['id'=>1]);
  131. $content_bloc = $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  132. $parametre = $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy([], ['id'=> 'ASC']);
  133. return $this->render('theme/'.$this->theme.'/component-blocks/contacts-listing-block.html.twig',[
  134. 'content_bloc'=> $content_bloc,
  135. 'param_contact'=> $param_contact,
  136. 'parametre'=> $parametre,
  137. ]);
  138. }
  139. public function displayContactHoursPage(){
  140. $content_bloc = $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  141. return $this->render('theme/'.$this->theme.'/component-blocks/contact-hours-block.html.twig',[
  142. 'content_bloc'=> $content_bloc,
  143. ]);
  144. }
  145. public function displayContactMap(){
  146. $param_contact = $this->getDoctrine()->getRepository(ParamContact::class)->findOneBy(['id'=>1]);
  147. $contacts = $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  148. return $this->render('theme/'.$this->theme.'/component-blocks/contact-map-block.html.twig',[
  149. 'contacts'=> $contacts,
  150. 'param_contact'=> $param_contact,
  151. ]);
  152. }
  153. public function displayOpenStreetMapWithContacts(){
  154. $param_contact = $this->getDoctrine()->getRepository(ParamContact::class)->findOneBy(['id'=>1]);
  155. $contacts = $this->getDoctrine()->getRepository(Contact::class)->getActifContacts();
  156. return $this->render('theme/'.$this->theme.'/component-blocks/osm-map-block.html.twig',[
  157. 'contacts'=> $contacts,
  158. 'param_contact'=> $param_contact,
  159. ]);
  160. }
  161. }