src/Controller/Front/PageController.php line 1103

Open in your IDE?
  1. <?php 
  2. namespace App\Controller\Front;
  3. use App\Entity\Menu;
  4. use App\Entity\Post;
  5. use App\Entity\UrlRef;
  6. use App\Entity\CpField;
  7. use App\Entity\UrlPost;
  8. use App\Entity\Category;
  9. use App\Entity\Language;
  10. use App\Entity\ListeRef;
  11. use App\Entity\MediaCms;
  12. use App\Entity\Secteurs;
  13. use App\Entity\TypePost;
  14. use App\Entity\Activites;
  15. use App\Entity\ListeMenu;
  16. use App\Service\BuildTree;
  17. use App\Entity\CpPostField;
  18. use App\Entity\PostArchive;
  19. use App\Service\RenderBloc;
  20. use Spatie\SchemaOrg\Graph;
  21. use App\Entity\ParametreRef;
  22. use App\Entity\PostCategory;
  23. use App\Service\MetaService;
  24. use Spatie\SchemaOrg\Schema;
  25. use App\Entity\ModelGallerie;
  26. use App\Entity\ParametrePost;
  27. use App\Entity\ParametreSite;
  28. use App\Entity\ReseauSociaux;
  29. use App\Service\MetaClePageRef;
  30. use App\Service\FunctionService;
  31. use App\Entity\ActiviteSecondaire;
  32. use Symfony\Component\Intl\Locale;
  33. use App\Service\RefMetaTagsService;
  34. use App\Service\AffichageGallerieService;
  35. use App\Service\MetaWithoutCategoryService;
  36. use Symfony\Component\HttpFoundation\Request;
  37. use Symfony\Component\HttpFoundation\Response;
  38. use Symfony\Component\Routing\Annotation\Route;
  39. use Symfony\Component\HttpFoundation\JsonResponse;
  40. use Leogout\Bundle\SeoBundle\Seo\Og\OgSeoGenerator;
  41. use Symfony\Component\String\Slugger\SluggerInterface;
  42. use Leogout\Bundle\SeoBundle\Seo\Basic\BasicSeoGenerator;
  43. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  44. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  45. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  46. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  47. class PageController extends AbstractController
  48. {
  49.     public $basicSeo;
  50.     public $seo;
  51.     private $slugger;
  52.     private $projectDir;
  53.     private $metaService;
  54.     private $metaClePageRef;
  55.     private $renderBloc;
  56.     private $buildTree;
  57.     private $functionService;
  58.     private $metaPostService;
  59.     private $theme;
  60.     private $refMetaTagsService;
  61.     private $affichageGallerieService;
  62.     protected $session;
  63.     
  64.     public function __construct(string $projectDir,string $theme,
  65.                                 BasicSeoGenerator $basicSeo,
  66.                                 OgSeoGenerator $seo,
  67.                                 RenderBloc $renderBloc,
  68.                                 RefMetaTagsService $refMetaTagsService,
  69.                                 SluggerInterface $slugger,
  70.                                 BuildTree $buildTree,
  71.                                 MetaService $metaService,
  72.                                 MetaWithoutCategoryService $metaPostService,
  73.                                 MetaClePageRef $metaClePageRef,
  74.                                 FunctionService $functionService,
  75.                                 AffichageGallerieService $affichageGallerieService,
  76.                                 SessionInterface $session){
  77.         $this->metaService $metaService;
  78.         $this->metaPostService $metaPostService;
  79.         $this->basicSeo $basicSeo;
  80.         $this->seo $seo;
  81.         $this->buildTree $buildTree;
  82.         $this->slugger $slugger;
  83.         $this->metaClePageRef $metaClePageRef;
  84.         $this->functionService $functionService;
  85.         $this->refMetaTagsService $refMetaTagsService;
  86.         $this->renderBloc $renderBloc;
  87.         $this->projectDir $projectDir;
  88.         $this->theme $theme;
  89.         $this->affichageGallerieService $affichageGallerieService;
  90.         $this->session $session;
  91.     }
  92.     /**
  93.      * @Route("/{slug}", name="page",priority="-1")
  94.      */
  95.     public function Page(Request $request,$slug,$page 1)
  96.     {
  97.         $_locale  $request->getLocale();
  98.         if ($slug == 'home') {
  99.             return $this->redirectToRoute('index_page_home');
  100.         }
  101.         if ($slug == 'contact-envoye' || $slug == 'contact-envoye-devis' || $slug == 'contact-landing-page') {
  102.             return $this->pageTraking($request,$slug);
  103.         }
  104.         
  105.         if($request->query->get('page')){
  106.             $page $request->query->get('page');
  107.         }
  108.         $product_interesse null;
  109.         if($request->query->get('product')){
  110.             $slug_product $request->query->get('product');
  111.             $product_interesse $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($slug_product);
  112.         }
  113.         $annonce_interesse null;
  114.         if($request->query->get('annonce')){
  115.             $slug_annonce $request->query->get('annonce');
  116.             $annonce_interesse $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($slug_annonce);
  117.         }
  118.         
  119.         $slug_info $this->getDoctrine()->getRepository(UrlPost::class)->findUrlBySlug($slug);
  120.         if(!$slug_info){
  121.             throw new NotFoundHttpException('Sorry not existing!');
  122.         }
  123.         if ($slug_info) {
  124.             $slug_lang $this->getDoctrine()->getRepository(UrlPost::class)->findLangUrl($slug);
  125.             if ($slug_lang['locale'] != $_locale) {
  126.                 $request->getSession()->set('_locale'$slug_lang['locale']);
  127.                 return $this->redirectToroute('page',['slug'=> $slug]);
  128.             }
  129.         }
  130.         if($slug_info->getType() === "Post"){
  131.             $this->MetaModulePostOrCategory($request,$slug,$slug_info);
  132.             $post $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($slug);
  133.             if($post == null){
  134.                 throw new NotFoundHttpException('Sorry not existing!');
  135.             }
  136.             if ($post->getTypePost()->getSystemName() == 'produits') {
  137.                 $render $this->pageProduit($request,$slug);
  138.             }elseif ($post->getTypePost()->getSystemName() == 'lp') {
  139.                 $render $this->pageLanding($request,$slug);
  140.             }else{
  141.                 if ($post->getTypePageRef() != null) {
  142.                     $render $this->pageRef($request,$slug);
  143.                 }else{
  144.                     $render $this->pagePost($request,$slug,$product_interesse,$annonce_interesse);
  145.                 }
  146.             }
  147.         }elseif ($slug_info->getType() === "Categorie"){
  148.             $this->MetaModulePostOrCategory($request,$slug,$slug_info);
  149.             $render $this->pageCatgorie($request,$slug,$page);
  150.         }elseif($slug_info->getType() === "Activite"){
  151.             $render $this->pageActivite($request,$slug,$slug_info);
  152.         }elseif($slug_info->getType() === "Activite_Secteur"){
  153.             $render $this->pageActiviteSecteur($request,$slug,$slug_info);
  154.         }elseif($slug_info->getType() === "Activite_Secondaire"){
  155.             $render $this->pageActiviteSecondaire($request,$slug,$slug_info);
  156.         }elseif ($slug_info->getType() === "Sous-categorie" || $slug_info->getType() === 'Sous-sous-categorie') {
  157.             throw new NotFoundHttpException('Sorry not existing!');
  158.         }
  159.  
  160.         return $render;
  161.     }
  162.     public function pageProduit($request,$slug){
  163.         $schemaOrg = new Graph();
  164.         $_locale $request->getLocale();
  165.         $post $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($slug);
  166.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  167.         $modele_galerie_choisie $post->getModeleGallerie() ? $post->getModeleGallerie()->getId() : 1;
  168.         $modele_gallerie $this->getDoctrine()->getRepository(ModelGallerie::class)->findById($modele_galerie_choisie);
  169.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  170.         $seo_image '';
  171.         $url $this->generateUrl('page', ['slug'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  172.         if ($this->functionService->parametreGenerale()) {
  173.             if ($this->functionService->parametreGenerale()->getApercuImageLien()) {
  174.                 $seo_image $baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getApercuImageLien();
  175.             }
  176.         }
  177.         $galleries_images = [];
  178.         $bloc_post $this->renderBloc->RenderBloc($post,$schemaOrg);
  179.         $module $post->getTypePost()->getSystemName();
  180.         $galleries $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$post->getId(),'media');
  181.         $galleries_images =  $this->affichageGallerieService->GallerieImages($galleries,$galleries_images);
  182.         $docs $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$post->getId(),'doc');
  183.         
  184.         $ListId = [];
  185.         if($post->getPostCategory()){
  186.             foreach($post->getPostCategory() as $value){
  187.                 $ListId[]= $value->getCategory()->getId();
  188.             }
  189.         }
  190.         $categorieTree null;
  191.         if (!empty($ListId)) {
  192.             $categories $this->getDoctrine()->getRepository(Category::class)->findCategoriePost($ListId);
  193.             $categorieTree $this->functionService->buildTree($categories); 
  194.         }
  195.         $meta_robots $post->getMetaRobots();
  196.         $custom_schemaOrg null;
  197.         if ($post->translate($_locale)->getSchema() != '') {
  198.             $custom_schemaOrg $post->translate($_locale)->getSchema();
  199.         }
  200.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  201.         $breadcrumb_item 1;
  202.         $breadcrumb = [];
  203.         $schema_breadcrumb_items = [];
  204.         $title_post_ariane $post->translate($_locale)->getBreadcrumb() ? $post->translate($_locale)->getBreadcrumb() : $post->translate($_locale)->getTitle();
  205.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane,'active'=> true];
  206.         $schema_breadcrumb_items[] = Schema::ListItem()
  207.                                    ->position(1)
  208.                                    ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  209.         $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
  210.                           'name'=> $post->translate($_locale)->getTitle(),'active'=> false];                        
  211.         $schema_breadcrumb_items[] = Schema::ListItem()
  212.                                     ->position($breadcrumb_item 1)
  213.                                     ->item(["@id"=> $this->generateUrl('page', ['slug'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=>$title_post_ariane]);
  214.           
  215.         if ($schema_breadcrumb_items) {
  216.             $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  217.         }
  218.         $schemaOrg->add(Schema::Article()->headline($title_post_ariane)
  219.                                          ->datePublished($post->getDatePublication()?$post->getDatePublication():$post->getCreatedAt())
  220.                                          ->dateModified($post->getUpdatedAt())
  221.                                          ->image($post->getImage()!= null?$baseurl.$post->getImage():'')
  222.                                          ->publisher(Schema::Organization()
  223.                                             ->name($this->functionService->parametreGenerale()?$this->functionService->parametreGenerale()->translate($_locale)->getTitre():'')
  224.                                             ->logo($this->functionService->parametreGenerale()?$baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getImage():''))
  225.                                          ->mainEntityOfPage(Schema::WebPage()->url($url))
  226.                                         );
  227.         
  228.         $url_social = [];
  229.         $social $this->getDoctrine()->getRepository(ReseauSociaux::class)->findAll();
  230.         if($social){
  231.             foreach ($social as $value) {
  232.                 $url_social[] = $value->getUrl();
  233.             }
  234.         }
  235.         // id categorie related with post 
  236.         $categoiesPosts $this->getDoctrine()->getRepository(PostCategory::class)->findCategorieByPost($post->getId());
  237.         $next_article $this->getDoctrine()->getRepository(Post::class)->findPostPrevOrNext($categoiesPosts,$post->getId());
  238.         $prev_article $this->getDoctrine()->getRepository(Post::class)->findPostPrevOrNext($categoiesPosts,$post->getId(),'prev');
  239.         $template_model_galerie $modele_gallerie[0]->getTwig();
  240.         $categories_tree = [];
  241.         $categories_principal =  $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> 0,'TypePost'=> $post->getTypePost()]);
  242.         if ($categories_principal) {
  243.             foreach ($categories_principal as $value) {
  244.                 $data_slug_sous_categorie = [];
  245.                 $tree_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> $value->getId()],['order_by'=>'ASC']);
  246.                 if($tree_sous_categorie){
  247.                     foreach ($tree_sous_categorie as $sous_categorie_items) {
  248.                         $data_slug_sous_sous_categorie = [];
  249.                         $tree_sous_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> $sous_categorie_items->getId()],['order_by'=>'ASC']);
  250.                         if ($tree_sous_sous_categorie) {
  251.                             foreach ($tree_sous_sous_categorie as  $sous_sous_categorie_items) {
  252.                                 $data_slug_sous_sous_categorie[] = [
  253.                                 'id'=> $sous_sous_categorie_items->getId(),
  254.                                 'titre'=> $sous_sous_categorie_items->translate($_locale)->getTitreCategorie(),
  255.                                 'slug'=> $sous_sous_categorie_items->translate($_locale)->getSlugUrl()];
  256.                             }
  257.                         }
  258.                         $data_slug_sous_categorie[] = ['id'=> $sous_categorie_items->getId(),
  259.                                                        'titre'=> $sous_categorie_items->translate($_locale)->getTitreCategorie(),
  260.                                                        'slug'=> $sous_categorie_items->translate($_locale)->getSlugUrl(),
  261.                                                        'sous_sous_categories'=> $data_slug_sous_sous_categorie,
  262.                                                       ];
  263.                     }
  264.                 }
  265.                 $categories_tree[] = ['id'=> $value->getId(),
  266.                                       'titre'=> $value->translate($_locale)->getTitreCategorie(),
  267.                                       'slug'=> $value->translate($_locale)->getSlugUrl(),
  268.                                       'sous_categories'=> $data_slug_sous_categorie,
  269.                                     ];
  270.             }
  271.         }
  272.         $parametre $this->functionService->parametreGenerale();
  273.         $produit_related null;
  274.          // Find product related with default categorie
  275.         // if($post->getDefaultCategorie()){
  276.         //     $canonical = $this->functionService->canonicalUrlProduit($post);
  277.         //     $produit_related = $this->getDoctrine()->getRepository(Post::class)->findProductRelated($post->getTypePost(),$post->getId(),$post->getDefaultCategorie());
  278.         // }else{
  279.         //     $canonical = $this->functionService->canonicalUrl($post->translate($_locale)->getCanonical());
  280.         // }
  281.         // Find product related 
  282.         if ($post->getPostsAssocies()) {
  283.             $canonical $this->functionService->canonicalUrlProduit($post);
  284.             foreach (explode(',',$post->getPostsAssocies()) as $id) {
  285.                 $produit =  $this->getDoctrine()->getRepository(Post::class)->find($id);
  286.                 if ($produit) {
  287.                     $produit_related[] = $produit;
  288.                 }
  289.             }
  290.         }else{
  291.             $canonical $this->functionService->canonicalUrl($post->translate($_locale)->getCanonical());
  292.         }
  293.         $champsPersonnalisesPost = [];
  294.         $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($post);
  295.      
  296.         $template =  $this->render('front/'.$this->theme.'/produits/page_produit.html.twig',[
  297.             'post'=> $post,
  298.             'produit_related'=> $produit_related,
  299.             'canonical'=> $canonical,
  300.             'parametre'=> $parametre,
  301.             'categories_tree'=> $categories_tree,
  302.             'title_home_ariane' => $title_home_ariane,
  303.             'galleries'=> $galleries_images,
  304.             'docs'=> $docs,
  305.             'blocs'=> $bloc_post,
  306.             'meta_robots'=> $meta_robots,
  307.             'schemaOrg'=> $schemaOrg,
  308.             'custom_schemaOrg'=> $custom_schemaOrg,
  309.             'next_article'=> $next_article,
  310.             'prev_article'=> $prev_article,
  311.             'modele_galerie' => $modele_gallerie,
  312.             'template_model_gallerie' => $template_model_galerie,
  313.             'champsPersonnalisesPost' => $champsPersonnalisesPost,
  314.             'breadcrumb'=> $breadcrumb
  315.         ]);
  316.         return $template;
  317.     }
  318.     public function pageRef($request,$slug){
  319.         $schemaOrg = new Graph();
  320.         $_locale $request->getLocale();
  321.         $post $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($slug);
  322.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  323.         $modele_galerie_choisie $post->getModeleGallerie() ? $post->getModeleGallerie()->getId() : 1;
  324.         $modele_gallerie $this->getDoctrine()->getRepository(ModelGallerie::class)->findById($modele_galerie_choisie);
  325.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  326.         $seo_image '';
  327.         $url $this->generateUrl('page', ['slug'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  328.         if ($this->functionService->parametreGenerale()) {
  329.             if ($this->functionService->parametreGenerale()->getApercuImageLien()) {
  330.                 $seo_image $baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getApercuImageLien();
  331.             }
  332.         }
  333.         $galleries_images = [];
  334.         $bloc_post $this->renderBloc->RenderBloc($post,$schemaOrg);
  335.         $module $post->getTypePost()->getSystemName();
  336.         $galleries $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$post->getId(),'media');
  337.         $galleries_images =  $this->affichageGallerieService->GallerieImages($galleries,$galleries_images);
  338.         $docs $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$post->getId(),'doc');
  339.         
  340.         $ListId = [];
  341.         if($post->getPostCategory()){
  342.             foreach($post->getPostCategory() as $value){
  343.                 $ListId[]= $value->getCategory()->getId();
  344.             }
  345.         }
  346.         $categorieTree null;
  347.         if (!empty($ListId)) {
  348.             $categories $this->getDoctrine()->getRepository(Category::class)->findCategoriePost($ListId);
  349.             $categorieTree $this->functionService->buildTree($categories); 
  350.         }
  351.         $meta_robots $post->getMetaRobots();
  352.         $custom_schemaOrg null;
  353.         if ($post->translate($_locale)->getSchema() != '') {
  354.             $custom_schemaOrg $post->translate($_locale)->getSchema();
  355.         }
  356.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  357.         $breadcrumb_item 1;
  358.         $breadcrumb = [];
  359.         $schema_breadcrumb_items = [];
  360.         $title_post_ariane $post->translate($_locale)->getBreadcrumb() ? $post->translate($_locale)->getBreadcrumb() : $post->translate($_locale)->getTitle();
  361.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane,'active'=> true];
  362.         $schema_breadcrumb_items[] = Schema::ListItem()
  363.                                    ->position(1)
  364.                                    ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  365.         
  366.         $titre_activite null;
  367.         $breadcrumb_item 1;
  368.         if ($post->getIdActivite() != null) {
  369.             $breadcrumb_item $breadcrumb_item 1;
  370.             $activite $this->getDoctrine()->getRepository(Activites::class)->find($post->getIdActivite());
  371.             if($activite){
  372.                 $titre_activite $activite->translate($_locale)->getTitreActivite();
  373.                 $title_breadcrumb_activite_primaire =  $activite->translate($_locale)->getBreadcrumb() ? $activite->translate($_locale)->getBreadcrumb() : $activite->translate($_locale)->getTitreActivite(); 
  374.                 $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=>  $activite->translate($_locale)->getLibelleUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  375.                                   'name'=> $title_breadcrumb_activite_primaire,'active'=> true];
  376.                 $schema_breadcrumb_items[] = Schema::ListItem()
  377.                                             ->position($breadcrumb_item)
  378.                                             ->item(["@id"=> $this->generateUrl('page', ['slug'=>  $activite->translate($_locale)->getLibelleUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  379.                                             "name"=> $title_breadcrumb_activite_primaire]);
  380.             } 
  381.         }
  382.         // if ($post->getIdSousActivite() != null) {
  383.         //     $breadcrumb_item = $breadcrumb_item + 1;
  384.         //     $activite_secondaire = $this->getDoctrine()->getRepository(ActiviteSecondaire::class)->find($post->getIdSousActivite());
  385.         //     if($activite_secondaire){
  386.         //         $title_breadcrumb_activite_secondaire =  $activite_secondaire->translate($_locale)->getBreadcrumb() ? $activite_secondaire->translate($_locale)->getBreadcrumb() : $activite_secondaire->translate($_locale)->getTitreActiviteSecondaire();
  387.         //         $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=>  $activite_secondaire->translate($_locale)->getLibelleUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  388.         //                           'name'=> $title_breadcrumb_activite_secondaire,'active'=> true];
  389.         //         $schema_breadcrumb_items[] = Schema::ListItem()
  390.         //                                     ->position($breadcrumb_item)
  391.         //                                     ->item(["@id"=> $this->generateUrl('page', ['slug'=>  $activite_secondaire->translate($_locale)->getLibelleUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  392.         //                                     "name"=> $title_breadcrumb_activite_secondaire]);
  393.         //     }
  394.         // }
  395.         $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
  396.                          'name'=> $post->translate($_locale)->getTitle(),'active'=> false];                        
  397.         $schema_breadcrumb_items[] = Schema::ListItem()
  398.                                     ->position($breadcrumb_item 1)
  399.                                     ->item(["@id"=> $this->generateUrl('page', ['slug'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=>$title_post_ariane]);
  400.         if ($schema_breadcrumb_items) {
  401.             $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  402.         }
  403.         $schemaOrg->add(Schema::Article()->headline($title_post_ariane)
  404.                                          ->datePublished($post->getDatePublication()?$post->getDatePublication():$post->getCreatedAt())
  405.                                          ->dateModified($post->getUpdatedAt())
  406.                                          ->image($post->getImage()!= null?$baseurl.$post->getImage():'')
  407.                                          ->publisher(Schema::Organization()
  408.                                             ->name($this->functionService->parametreGenerale()?$this->functionService->parametreGenerale()->translate($_locale)->getTitre():'')
  409.                                             ->logo($this->functionService->parametreGenerale()?$baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getImage():''))
  410.                                          ->mainEntityOfPage(Schema::WebPage()->url($url))
  411.                                         );
  412.         
  413.         $url_social = [];
  414.         $social $this->getDoctrine()->getRepository(ReseauSociaux::class)->findAll();
  415.         if($social){
  416.             foreach ($social as $value) {
  417.                 $url_social[] = $value->getUrl();
  418.             }
  419.         }
  420.         // id categorie related with post 
  421.         $categoiesPosts $this->getDoctrine()->getRepository(PostCategory::class)->findCategorieByPost($post->getId());
  422.         $next_article $this->getDoctrine()->getRepository(Post::class)->findPostPrevOrNext($categoiesPosts,$post->getId());
  423.         $prev_article $this->getDoctrine()->getRepository(Post::class)->findPostPrevOrNext($categoiesPosts,$post->getId(),'prev');
  424.         $template_model_galerie $modele_gallerie[0]->getTwig();
  425.         $parametre $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy(['Site'=>'1']);
  426.  
  427.         $secteur $this->getDoctrine()->getRepository(Secteurs::class)->find($post->getIdSecteur());
  428.        // $actualite_ref = $this->getDoctrine()->getRepository(Post::class)->findPostByIdSecteur($post->getId(),$post->getIdActivite(),$post->getIdSecteur());
  429.         
  430.         $ref_pages null;
  431.         $actualites_liee = [];
  432.         
  433.         if($post->getIdActivite() != null and $post->getIdSousActivite() == null){
  434.             $ref_pages $this->getDoctrine()->getRepository(Post::class)->findPageRefByIdActivite($post->getIdActivite(),$post->getId());
  435.             $actualites_liee $this->getDoctrine()->getRepository(Post::class)->findPageClientByIdActiviteOrSousActivite($post->getIdActivite());
  436.         }elseif($post->getIdActivite() != null and $post->getIdSousActivite() != null){
  437.             $ref_pages $this->getDoctrine()->getRepository(Post::class)->findPageRefByIdActiviteAndIdSousActivite($post->getIdActivite(),$post->getIdSousActivite(),$post->getId());
  438.             $actualites_liee $this->getDoctrine()->getRepository(Post::class)->findPageClientByIdActiviteAndSousActivite($post->getIdActivite(),$post->getIdSousActivite());
  439.         }
  440.         $ref_pages_sous_activite $this->getDoctrine()->getRepository(Post::class)->findPageRefByIdsSousActiviteAndActivitePrincipal($post->getIdActivite(),$post->getIdSecteur());
  441.         $parametreRef $this->getDoctrine()->getRepository(ParametreRef::class)->findOneBy(['alias'=> 'param_generale']);
  442.         $canonical $this->functionService->canonicalUrl($post->translate($_locale)->getCanonical());
  443.         $template =  $this->render('front/'.$this->theme.'/page_ref.html.twig',[
  444.             'post'=> $post,
  445.             'canonical'=> $canonical,
  446.             'ref_pages'=> $ref_pages,
  447.             'titre_activite'=> $titre_activite,
  448.             'ref_pages_sous_activite'=> $ref_pages_sous_activite,
  449.             'actualites_liee'=> $actualites_liee,
  450.             'parametreRef'=> $parametreRef,
  451.             'secteur'=> $secteur,
  452.             'title_home_ariane' => $title_home_ariane,
  453.             'galleries'=> $galleries_images,
  454.             'docs'=> $docs,
  455.             'blocs'=> $bloc_post,
  456.             'meta_robots'=> $meta_robots,
  457.             'schemaOrg'=> $schemaOrg,
  458.             'custom_schemaOrg'=> $custom_schemaOrg,
  459.             'parametre'=> $parametre,
  460.             'next_article'=> $next_article,
  461.             'prev_article'=> $prev_article,
  462.             'modele_galerie' => $modele_gallerie,
  463.             'template_model_gallerie' => $template_model_galerie,
  464.             'breadcrumb'=> $breadcrumb
  465.         ]);
  466.         return $template;
  467.     }
  468.     public function pageLanding($request,$slug){
  469.         $schemaOrg = new Graph();
  470.         $_locale $request->getLocale();
  471.         $post $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($slug);
  472.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  473.         $modele_galerie_choisie $post->getModeleGallerie() ? $post->getModeleGallerie()->getId() : 1;
  474.         $modele_gallerie $this->getDoctrine()->getRepository(ModelGallerie::class)->findById($modele_galerie_choisie);
  475.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  476.         $seo_image '';
  477.         $url $this->generateUrl('page', ['slug'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  478.         if ($this->functionService->parametreGenerale()) {
  479.             if ($this->functionService->parametreGenerale()->getApercuImageLien()) {
  480.                 $seo_image $baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getApercuImageLien();
  481.             }
  482.         }
  483.         $bloc_post $this->renderBloc->RenderBloc($post,$schemaOrg);
  484.         
  485.         return $this->render('front/'.$this->theme.'/landing-page/page.html.twig',[
  486.             'blocs'=> $bloc_post,
  487.         ]);
  488.     }
  489.     public function pagePost($request,$slug,$product_interesse null,$annonce_interesse null){
  490.         $schemaOrg = new Graph();
  491.         $_locale $request->getLocale();
  492.         $post $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($slug);
  493.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  494.         $modele_galerie_choisie $post->getModeleGallerie() ? $post->getModeleGallerie()->getId() : 1;
  495.         $modele_gallerie $this->getDoctrine()->getRepository(ModelGallerie::class)->findById($modele_galerie_choisie);
  496.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  497.         $seo_image '';
  498.         $url $this->generateUrl('page', ['slug'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  499.         if ($this->functionService->parametreGenerale()) {
  500.             if ($this->functionService->parametreGenerale()->getApercuImageLien()) {
  501.                 $seo_image $baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getApercuImageLien();
  502.             }
  503.         }
  504.         $all_posts_associes = [];
  505.         if($post->getPostsAssocies()){
  506.             $posts_associes explode(',',$post->getPostsAssocies());
  507.             foreach ($posts_associes as $post_associe){
  508.                 $all_posts_associes[] = $this->getDoctrine()->getRepository(Post::class)->findPostById($post_associe);
  509.             }
  510.         }
  511.         $all_others_posts_associes = [];
  512.         if($post->getPostsAssociesAutresTypes()){
  513.             $others_posts_associes explode(',',$post->getPostsAssociesAutresTypes());
  514.             foreach ($others_posts_associes as $other_post_associe){
  515.                 $all_others_posts_associes[] = $this->getDoctrine()->getRepository(Post::class)->findOneBy(['id' => $other_post_associe]);
  516.             }
  517.         }
  518.         
  519.         $galleries_images = [];
  520.         $bloc_post $this->renderBloc->RenderBloc($post,$schemaOrg);
  521.         $module $post->getTypePost()->getSystemName();
  522.         $galleries $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$post->getId(),'media');
  523.         $galleries_images =  $this->affichageGallerieService->GallerieImages($galleries,$galleries_images);
  524.         $docs $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$post->getId(),'doc');
  525.         
  526.         $ListId = [];
  527.         if($post->getPostCategory()){
  528.             foreach($post->getPostCategory() as $value){
  529.                 $ListId[]= $value->getCategory()->getId();
  530.             }
  531.         }
  532.         $categorieTree null;
  533.         if (!empty($ListId)) {
  534.             $categories $this->getDoctrine()->getRepository(Category::class)->findCategoriePost($ListId);
  535.             $categorieTree $this->functionService->buildTree($categories); 
  536.         }
  537.         $meta_robots $post->getMetaRobots();
  538.         $custom_schemaOrg null;
  539.         if ($post->translate($_locale)->getSchema() != '') {
  540.             $custom_schemaOrg $post->translate($_locale)->getSchema();
  541.         }
  542.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  543.         $breadcrumb_item 1;
  544.         $schema_breadcrumb_items = [];
  545.         $schema_breadcrumb_items[] = Schema::ListItem()
  546.                                    ->position(1)
  547.                                    ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=>$title_home_ariane]);
  548.         if($categorieTree){
  549.             foreach ($categorieTree as $value) {
  550.                 $breadcrumb_item $breadcrumb_item 1;
  551.                 $schema_breadcrumb_items[] = Schema::ListItem()
  552.                                             ->position($breadcrumb_item)
  553.                                             ->item(["@id"=> $this->generateUrl('page', ['slug'=> $value['slug']], UrlGeneratorInterface::ABSOLUTE_URL),"name"=>$value['titre']]);
  554.             }
  555.         }
  556.         
  557.         $title_post_ariane $post->translate($_locale)->getBreadcrumb() ? $post->translate($_locale)->getBreadcrumb() : $post->translate($_locale)->getTitle();
  558.         $schema_breadcrumb_items[] = Schema::ListItem()
  559.                                     ->position($breadcrumb_item 1)
  560.                                     ->item(["@id"=> $this->generateUrl('page', ['slug'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=>$title_post_ariane]);
  561.         if ($schema_breadcrumb_items) {
  562.             $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  563.         }
  564.         $schemaOrg->add(Schema::Article()->headline($title_post_ariane)
  565.                                          ->datePublished($post->getDatePublication()?$post->getDatePublication():$post->getCreatedAt())
  566.                                          ->dateModified($post->getUpdatedAt())
  567.                                          ->image($post->getImage()!= null?$baseurl.$post->getImage():'')
  568.                                          ->publisher(Schema::Organization()
  569.                                          ->name($this->functionService->parametreGenerale()?$this->functionService->parametreGenerale()->translate($_locale)->getTitre():'')
  570.                                          ->logo($this->functionService->parametreGenerale()?$baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getImage():''))
  571.                                          ->mainEntityOfPage(Schema::WebPage()->url($url))
  572.                                         );
  573.         
  574.         $url_social = [];
  575.         $social $this->getDoctrine()->getRepository(ReseauSociaux::class)->findAll();
  576.         if($social){
  577.             foreach ($social as $value) {
  578.                 $url_social[] = $value->getUrl();
  579.             }
  580.         }
  581.         // id categorie related with post 
  582.         $categoiesPosts $this->getDoctrine()->getRepository(PostCategory::class)->findCategorieByPost($post->getId());
  583.         $next_article $this->getDoctrine()->getRepository(Post::class)->findPostPrevOrNext($categoiesPosts,$post->getId());
  584.         $prev_article $this->getDoctrine()->getRepository(Post::class)->findPostPrevOrNext($categoiesPosts,$post->getId(),'prev');
  585.         $template_model_galerie $modele_gallerie[0]->getTwig();
  586.         $parametre $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy(['Site'=>'1']);
  587.  
  588.         $canonical $this->functionService->canonicalUrl($post->translate($_locale)->getCanonical());
  589.         if($module == 'recrutement'){
  590.             $annonce_related null;
  591.             $annonce_related $this->getDoctrine()->getRepository(Post::class)->findRelatedAnnonces($post->getTypePost(),$post->getId());
  592.             $champs_personnalises_related_annonces = [];
  593.             if($annonce_related){
  594.                 foreach($annonce_related as $annonce){
  595.                     // Champs personnalisés
  596.                     $champsPersonnalisesAnnonces = [];
  597.                     $champsPersonnalisesAnnonces $this->functionService->getChampsPersonnalisesPost($annonce);
  598.                     
  599.                     $champs_personnalises_related_annonces[] = [
  600.                         'id_post' => $annonce->getId(),
  601.                         'champs_personnalises_post' => $champsPersonnalisesAnnonces
  602.                     ];
  603.                 }
  604.             }
  605.         }
  606.         if($post->getTemplateCms()){
  607.     
  608.             $template $this->render('front/'.$this->theme.'/dynamique-page-cms.html.twig',[
  609.                  'template'=> $post->getTemplateCms()->getTwig(),
  610.                  'post'=> $post,
  611.                  'canonical'=> $canonical,
  612.                  'title_home_ariane' => $title_home_ariane,
  613.                  'galleries'=> $galleries_images,
  614.                  'bloc_post'=> $bloc_post,
  615.                  'categorieTree'=> $categorieTree,
  616.                  'meta_robots'=> $meta_robots,
  617.                  'schemaOrg'=> $schemaOrg,
  618.                  'custom_schemaOrg'=> $custom_schemaOrg,
  619.                  'parametre'=> $parametre,
  620.                  'product_interesse'=> $product_interesse,
  621.                  'annonce_interesse'=> $annonce_interesse,
  622.                  'next_article'=> $next_article,
  623.                  'prev_article'=> $prev_article,
  624.                  'modele_galerie' => $modele_gallerie,
  625.                  'template_model_gallerie' => $template_model_galerie,
  626.                  'all_posts_associes' => $all_posts_associes,
  627.                  'all_others_posts_associes' => $all_others_posts_associes
  628.            ]);
  629.            
  630.         }else{
  631.             // Champs personnalisés
  632.             $champsPersonnalisesPost = [];
  633.             $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($post);
  634.             $ref_pages_principal null;
  635.             $ref_pages_secondaire null;
  636.             if ($post->getIdActivite()) {
  637.                 $ref_pages_principal $this->getDoctrine()->getRepository(Post::class)->findPageRefByIdActivite($post->getIdActivite());
  638.             }
  639.             if ($post->getIdSousActivite()) {
  640.                 $ref_pages_secondaire $this->getDoctrine()->getRepository(Post::class)->findPageRefByIdSousActivite($post->getIdSousActivite());
  641.             }
  642.             $parametreRef $this->getDoctrine()->getRepository(ParametreRef::class)->findOneBy(['alias'=> 'param_generale']);
  643.             if($module == 'recrutement'){
  644.                 $template =  $this->render('front/'.$this->theme.'/page_annonce_detail.html.twig',[
  645.                     'post'=> $post,
  646.                     'canonical'=> $canonical,
  647.                     'ref_pages_principal'=> $ref_pages_principal,
  648.                     'parametreRef'=> $parametreRef,
  649.                     'ref_pages_secondaire'=> $ref_pages_secondaire,
  650.                     'title_home_ariane' => $title_home_ariane,
  651.                     'galleries'=> $galleries_images,
  652.                     'docs'=> $docs,
  653.                     'blocs'=> $bloc_post,
  654.                     'product_interesse'=> $product_interesse,
  655.                     'annonce_interesse'=> $annonce_interesse,
  656.                     'categorieTree'=> $categorieTree,
  657.                     'meta_robots'=> $meta_robots,
  658.                     'schemaOrg'=> $schemaOrg,
  659.                     'custom_schemaOrg'=> $custom_schemaOrg,
  660.                     'champsPersonnalisesPost'=> $champsPersonnalisesPost,
  661.                     'parametre'=> $parametre,
  662.                     'next_article'=> $next_article,
  663.                     'prev_article'=> $prev_article,
  664.                     'modele_galerie' => $modele_gallerie,
  665.                     'template_model_gallerie' => $template_model_galerie,
  666.                     'all_posts_associes' => $all_posts_associes,
  667.                     'annonce_related'=> $annonce_related,
  668.                     'champs_personnalises_related_annonces' => $champs_personnalises_related_annonces
  669.                 ]);
  670.             }else{
  671.                 $template =  $this->render('front/'.$this->theme.'/page_cms.html.twig',[
  672.                     'post'=> $post,
  673.                     'canonical'=> $canonical,
  674.                     'ref_pages_principal'=> $ref_pages_principal,
  675.                     'parametreRef'=> $parametreRef,
  676.                     'ref_pages_secondaire'=> $ref_pages_secondaire,
  677.                     'title_home_ariane' => $title_home_ariane,
  678.                     'galleries'=> $galleries_images,
  679.                     'docs'=> $docs,
  680.                     'blocs'=> $bloc_post,
  681.                     'product_interesse'=> $product_interesse,
  682.                     'annonce_interesse'=> $annonce_interesse,
  683.                     'categorieTree'=> $categorieTree,
  684.                     'meta_robots'=> $meta_robots,
  685.                     'schemaOrg'=> $schemaOrg,
  686.                     'custom_schemaOrg'=> $custom_schemaOrg,
  687.                     'champsPersonnalisesPost'=> $champsPersonnalisesPost,
  688.                     'parametre'=> $parametre,
  689.                     'next_article'=> $next_article,
  690.                     'prev_article'=> $prev_article,
  691.                     'modele_galerie' => $modele_gallerie,
  692.                     'template_model_gallerie' => $template_model_galerie,
  693.                     'all_posts_associes' => $all_posts_associes,
  694.                     'all_others_posts_associes' => $all_others_posts_associes
  695.                 ]);
  696.             }
  697.         }
  698.         return $template;
  699.     }
  700.     public function pageCatgorie($request,$slug,$page){
  701.         $module 'category';
  702.         $resultats = [];
  703.         $schemaOrg = new Graph();
  704.         $_locale $request->getLocale();
  705.         $categorie $this->getDoctrine()->getRepository(Category::class)->findCategoryBySlug($slug);
  706.         if(!$categorie){
  707.             throw new NotFoundHttpException('Sorry not existing!');
  708.         }
  709.         $type_post $categorie->getTypePost();
  710.         $parametrePost $this->getDoctrine()->getRepository(ParametrePost::class)->findOneBy(['TypePost'=> $type_post]);
  711.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  712.         $template $categorie->getTypeAffichageHome();
  713.         $bloc_categorie $this->renderBloc->RenderBloc($categorie,$schemaOrg,'categorie');
  714.         // Galleries
  715.         $galleries_images = [];
  716.         $modele_galerie_choisie $categorie->getModeleGallerie() ? $categorie->getModeleGallerie()->getId() : 1;
  717.         $modele_gallerie $this->getDoctrine()->getRepository(ModelGallerie::class)->findById($modele_galerie_choisie);
  718.         $galleries $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$categorie->getId(),'media');
  719.         $galleries_images =  $this->affichageGallerieService->GallerieImages($galleries,$galleries_images);
  720.         $template_model_galerie $modele_gallerie[0]->getTwig();
  721.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  722.         $meta_robots $categorie->getMetaRobots();
  723.         $breadcrumb = [];
  724.         $schema_breadcrumb_items = [];
  725.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),'name'=> $title_home_ariane,'active'=> true];
  726.         $schema_breadcrumb_items[] = Schema::ListItem()
  727.                                    ->position(1)
  728.                                    ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  729.         $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=> $categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),'name'=> $categorie->translate($_locale)->getTitreCategorie(),'active'=> false];
  730.         $schema_breadcrumb_items[] = Schema::ListItem()
  731.                                     ->position(2)
  732.                                     ->item(["@id"=> $this->generateUrl('page', ['slug'=> $categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $categorie->translate($_locale)->getTitreCategorie()]);
  733.         if ($schema_breadcrumb_items) {
  734.             $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  735.         }
  736.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  737.         $schemaOrg->add(Schema::Article()
  738.                             ->headline($categorie->translate($_locale)->getTitreCategorie())
  739.                             ->datePublished($categorie->getCreatedAt())
  740.                             ->dateModified($categorie->getUpdatedAt())
  741.                             ->image($categorie->getImage()!= null?$baseurl.$categorie->getImage():'')
  742.                             ->publisher(Schema::Organization()
  743.                             ->name($this->functionService->parametreGenerale()?$this->functionService->parametreGenerale()->translate($_locale)->getTitre():'')
  744.                             ->logo($this->functionService->parametreGenerale()?$baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getImage():''))
  745.                             ->mainEntityOfPage(Schema::WebPage()->url($this->generateUrl('page', ['slug'=> $categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL)))
  746.                         );
  747.         $module $categorie->getTypePost()->translate($_locale)->getSystemName();
  748.         $galleries $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$categorie->getId(),'media');
  749.         $docs $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$categorie->getId(),'doc');
  750.         $parametre $this->functionService->parametreGenerale();
  751.         $categories_tree = [];
  752.         $categories_principal =  $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> 0,'TypePost'=> $categorie->getTypepost()]);
  753.         if ($categories_principal) {
  754.             foreach ($categories_principal as $value) {
  755.                 $data_slug_sous_categorie = [];
  756.                 $sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> $value->getId()],['order_by'=>'ASC']);
  757.                 if($sous_categorie){
  758.                     foreach ($sous_categorie as $sous_categorie_items) {
  759.                         $data_slug_sous_sous_categorie = [];
  760.                         $sous_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> $sous_categorie_items->getId()],['order_by'=>'ASC']);
  761.                         if ($sous_sous_categorie) {
  762.                             foreach ($sous_sous_categorie as $sous_sous_categorie_items) {
  763.                                 $data_slug_sous_sous_categorie[] = ['id'=> $sous_sous_categorie_items->getId(),
  764.                                                                     'titre'=> $sous_sous_categorie_items->translate($_locale)->getTitreCategorie(),
  765.                                                                     'slug'=> $sous_sous_categorie_items->translate($_locale)->getSlugUrl()];
  766.                             }
  767.                         }
  768.                         $data_slug_sous_categorie[] = ['id'=> $sous_categorie_items->getId(),
  769.                                                        'titre'=> $sous_categorie_items->translate($_locale)->getTitreCategorie(),
  770.                                                        'slug'=> $sous_categorie_items->translate($_locale)->getSlugUrl(),
  771.                                                        'sous_sous_categories'=> $data_slug_sous_sous_categorie,
  772.                                                       ];
  773.                     }
  774.                 }
  775.                 $categories_tree[] = ['id'=> $value->getId(),
  776.                                       'titre'=> $value->translate($_locale)->getTitreCategorie(),
  777.                                       'slug'=> $value->translate($_locale)->getSlugUrl(),
  778.                                       'sous_categories'=> $data_slug_sous_categorie,
  779.                                     ];
  780.             }
  781.         }
  782.         if ($parametrePost && $parametrePost->getShowCategories()) {
  783.             $sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> $categorie->getId()],['order_by'=>'ASC']);
  784.             if ($sous_categorie) {
  785.                 $posts $this->getDoctrine()->getRepository(Category::class)->findSousCategorie($categorie,$page);
  786.                 $postItems $categorie->getPagination() == true ?$posts->getResults():$posts;
  787.                 if ($postItems) {
  788.                     foreach ($postItems as $value) {
  789.                         $resultats[] = [ 'id'=> $value->getId(),
  790.                                          'slug'=> $value->translate($_locale)->getSlugUrl(),
  791.                                          'slug_categorie_parent'=> $categorie->translate($_locale)->getSlugUrl(),
  792.                                          'page_produit'=> $categorie->getTypepost()->getSystemName() == 'produits'?true:false,
  793.                                          'titre'=> $value->translate($_locale)->getTitreCategorie(),
  794.                                          'title_affichage'=> null,
  795.                                          'content'=> $value->translate($_locale)->getTexteCategorie(),
  796.                                          'chapeau'=> $value->translate($_locale)->getChapeauCategorie(),
  797.                                          'image'=> $value->getImage(),
  798.                                          'typelien'=> $value->getTypeLien(),
  799.                                          'titrelien'=> $value->getTitreLien(),
  800.                                          'telephone'=> $value->getTelephone(),
  801.                                          'lieninterne'=> $value->getLienInterne(),
  802.                                          'lienexterne'=> $value->getLienExterne(),
  803.                                        ];
  804.                     }
  805.                 }
  806.             }else{
  807.                 $posts $this->getDoctrine()->getRepository(Post::class)->findPostBySpecifiqueCategory($categorie,$page,$this->functionService->findRelatedIdsByCategorie($categories_tree,$categorie->getId(),'1'));
  808.                 $postItems $categorie->getPagination() == true ?$posts->getResults():$posts;
  809.                 if ($postItems) {
  810.                     foreach ($postItems as $value) {
  811.     
  812.                         $galleries_first_image $this->affichageGallerieService->FirstGallerieImagePost($value);
  813.                         // Champs personnalisés
  814.                         $champsPersonnalisesPost = [];
  815.                         $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($value);
  816.     
  817.                         $resultats[] = [ 'id'=> $value->getId(),
  818.                                          'slug'=> $value->getSlug(),
  819.                                          'titre'=> $value->getTitle(),
  820.                                          'title_affichage'=> $value->getTitleAffichage(),
  821.                                          'slug_categorie_parent'=> $categorie->translate($_locale)->getSlugUrl(),
  822.                                          'page_produit'=> $categorie->getTypepost()->getSystemName() == 'produits'?true:false,
  823.                                          'content'=> $value->getContent(),
  824.                                          'chapeau'=> $value->getSummary(),
  825.                                          'image'=> $value->getImage(),
  826.                                          'image_couverture'=> $value->getImageCouverture(),
  827.                                          'galleries_first_image'=> $galleries_first_image,
  828.                                          'typelien'=> $value->getTypeLien(),
  829.                                          'titrelien'=> $value->getTitreLien(),
  830.                                          'telephone'=> $value->getTelephone(),
  831.                                          'lieninterne'=> $value->getLienInterne(),
  832.                                          'lienexterne'=> $value->getLienExterne(),
  833.                                          'prixproduit'=> $value->getPrixProduit(),
  834.                                          'champsPersonnalisesPost' => $champsPersonnalisesPost];
  835.                     }
  836.                 }
  837.             }
  838.         }else{
  839.             $posts $this->getDoctrine()->getRepository(Post::class)->findPostBySpecifiqueCategory($categorie,$page,$this->functionService->findRelatedIdsByCategorie($categories_tree,$categorie->getId(),'1'));
  840.             $postItems $categorie->getPagination() == true ?$posts->getResults():$posts;
  841.             if ($postItems) {
  842.                 foreach ($postItems as $value) {
  843.                     $galleries_first_image $this->affichageGallerieService->FirstGallerieImagePost($value);
  844.                     // Champs personnalisés
  845.                     $champsPersonnalisesPost = [];
  846.                     $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($value);
  847.                     $resultats[] = [ 'id'=> $value->getId(),
  848.                                      'slug'=> $value->getSlug(),
  849.                                      'titre'=> $value->getTitle(),
  850.                                      'title_affichage'=> $value->getTitleAffichage(),
  851.                                      'slug_categorie_parent'=> $categorie->translate($_locale)->getSlugUrl(),
  852.                                      'page_produit'=> $categorie->getTypepost()->getSystemName() == 'produits'?true:false,
  853.                                      'content'=> $value->getContent(),
  854.                                      'chapeau'=> $value->getSummary(),
  855.                                      'image'=> $value->getImage(),
  856.                                      'image_couverture'=> $value->getImageCouverture(),
  857.                                      'galleries_first_image'=> $galleries_first_image,
  858.                                      'typelien'=> $value->getTypeLien(),
  859.                                      'titrelien'=> $value->getTitreLien(),
  860.                                      'telephone'=> $value->getTelephone(),
  861.                                      'lieninterne'=> $value->getLienInterne(),
  862.                                      'lienexterne'=> $value->getLienExterne(),
  863.                                      'prixproduit'=> $value->getPrixProduit(),
  864.                                      'champsPersonnalisesPost' => $champsPersonnalisesPost];
  865.                 }
  866.             }
  867.         }
  868.         
  869.         if ($categorie->getTypepost()->getSystemName() == 'produits') {
  870.             $template $this->render('front/'.$this->theme.'/produits/page_categorie.html.twig',[
  871.                 'template'=> $template,
  872.                 'title_home_ariane' => $title_home_ariane,
  873.                 'categorie'=> $categorie,
  874.                 'categories_tree'=> $categories_tree,
  875.                 'breadcrumb'=> $breadcrumb,
  876.                 'resultats'=> $resultats,
  877.                 'blocs'=> $bloc_categorie,
  878.                 'posts'=> $posts,
  879.                 'meta_robots'=> $meta_robots,
  880.                 'pagination'=> $categorie->getPagination(),
  881.                 'schemaOrg'=> $schemaOrg,
  882.                 'galleries'=> $galleries_images,
  883.                 'docs'=> $docs,
  884.                 'parametre'=> $parametre,
  885.                 'modele_galerie' => $modele_gallerie,
  886.                 'template_model_gallerie' => $template_model_galerie,
  887.                 'param_post' => $parametrePost,
  888.                 'show_filter_categorie'=> $type_post->getFilterCategorie()
  889.             ]);
  890.         }else {
  891.             $template $this->render('front/'.$this->theme.'/page_categorie.html.twig',[
  892.                 'template'=> $template,
  893.                 'title_home_ariane' => $title_home_ariane,
  894.                 'categorie'=> $categorie,
  895.                 'resultats'=> $resultats,
  896.                 'blocs'=> $bloc_categorie,
  897.                 'posts'=> $posts,
  898.                 'meta_robots'=> $meta_robots,
  899.                 'pagination'=> $categorie->getPagination(),
  900.                 'schemaOrg'=> $schemaOrg,
  901.                 'galleries'=> $galleries_images,
  902.                 'docs'=> $docs,
  903.                 'parametre'=> $parametre,
  904.                 'modele_galerie' => $modele_gallerie,
  905.                 'template_model_gallerie' => $template_model_galerie,
  906.             ]);
  907.         }
  908.         
  909.         return $template;
  910.     }
  911.     public function pageActivite($request,$slug,$slug_info){
  912.         $_locale $request->getLocale();
  913.         $activite $this->getDoctrine()->getRepository(Activites::class)->findActiviteBySlug($slug);
  914.         $titre $activite->translate($_locale)->getTitre();
  915.         $titre_activite $activite->translate($_locale)->getTitreActivite();
  916.         $texte $activite->translate($_locale)->getTextActivitePrincipalFinal();
  917.         $meta_tags $this->metaService->generateMetaPage($activite,'activite');
  918.         if ($meta_tags) {
  919.             $this->basicSeo->setTitle($meta_tags['title'])
  920.                            ->setDescription($meta_tags['description']);
  921.         }
  922.         $secteurs = [];
  923.         $all_secteurs $this->getDoctrine()->getRepository(Secteurs::class)->findBy(['actif'=> true]);
  924.         if ($all_secteurs) {
  925.             foreach ($all_secteurs as $secteur) {
  926.                if(in_array($activite->getId(),explode(',',$secteur->getActivitePrimaireIds()))){
  927.                    $secteurs[] = $secteur;
  928.                }
  929.             }
  930.         }
  931.         
  932.         $medias $this->getDoctrine()->getRepository(MediaCms::class)->findBy(['module'=>'Activite','module_id'=>$activite->getId()]);
  933.         $ref_pages $this->getDoctrine()->getRepository(Post::class)->findPageRefByIdActivite($activite->getId());
  934.       
  935.         $actualites $this->getDoctrine()->getRepository(Post::class)->findPageClientByIdActiviteOrSousActivite($activite->getId());
  936.         $parametre $this->functionService->parametreGenerale();
  937.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  938.         $title_home_ariane $home->translate($_locale)->getBreadcrumb() ? $home->translate($_locale)->getBreadcrumb() : "Accueil";
  939.         $schemaOrg = new Graph();
  940.         $breadcrumb = [];
  941.         $schema_breadcrumb_items = [];
  942.         
  943.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane,'active'=> true];
  944.         $schema_breadcrumb_items[] = Schema::ListItem()
  945.                                      ->position(1)
  946.                                      ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  947.         
  948.         $title_breadcrumb_activite =  $activite->translate($_locale)->getBreadcrumb() ? $activite->translate($_locale)->getBreadcrumb() : $titre_activite;
  949.         $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=>  $activite->translate($_locale)->getLibelleUrl()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_breadcrumb_activite,'active'=> false];
  950.         $schema_breadcrumb_items[] = Schema::ListItem()
  951.                                     ->position(2)
  952.                                     ->item(["@id"=> $this->generateUrl('page', ['slug'=>  $activite->translate($_locale)->getLibelleUrl()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_breadcrumb_activite]);
  953.    
  954.         $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  955.         
  956.         $meta_tags $this->refMetaTagsService->generateMetaPage($activite,'activite');
  957.         if ($meta_tags) {
  958.             $this->basicSeo->setTitle($meta_tags['title'])
  959.                            ->setDescription($meta_tags['description']);
  960.         }
  961.         $ref_pages_sous_activite $this->getDoctrine()->getRepository(Post::class)->findPageRefByIdsSousActiviteAndActivitePrincipal($activite->getId());
  962.     
  963.         $parametreRef $this->getDoctrine()->getRepository(ParametreRef::class)->findOneBy(['alias'=> 'param_generale']);
  964.         $template =  $this->render('front/'.$this->theme.'/page_activite.html.twig',[
  965.             'titre'=> $titre,
  966.             'texte'=> $texte,
  967.             'titre_activite'=> $titre_activite,
  968.             'slug'=> $slug,
  969.             'parametreRef'=> $parametreRef,
  970.             'activite'=> $activite,
  971.             'medias'=> $medias,
  972.             'ref_pages'=> $ref_pages,
  973.             'ref_pages_sous_activite'=> $ref_pages_sous_activite,
  974.             'actualites'=> $actualites,
  975.             'parametre'=> $parametre,
  976.             'secteurs'=> $secteurs,
  977.             'breadcrumb'=> $breadcrumb,
  978.             'schemaOrg'=> $schemaOrg,
  979.         ]);
  980.         return $template;
  981.     }
  982.     public function pageActiviteSecondaire($request,$slug,$slug_info){
  983.         $_locale $request->getLocale();
  984.         $activite_primaire_titre null;
  985.         $activite_primaire_slug null;
  986.         $activite_secondaire $this->getDoctrine()->getRepository(ActiviteSecondaire::class)->findActiviteBySlug($slug);
  987.         if ($activite_secondaire->getActivitePrimaire()) {
  988.             return $this->redirectToRoute('page',['slug'=> $activite_secondaire->getActivitePrimaire()->translate($_locale)->getLibelleUrl()]);
  989.             $activite_primaire_titre =  $activite_secondaire->getActivitePrimaire()->translate($_locale)->getTitreActivite();
  990.             $activite_primaire_slug $activite_secondaire->getActivitePrimaire()->translate($_locale)->getLibelleUrl();
  991.         }
  992.         $titre $activite_secondaire->translate($_locale)->getTitre();
  993.         $titre_activite $activite_secondaire->translate($_locale)->getTitreActiviteSecondaire();
  994.         $texte $activite_secondaire->translate($_locale)->getTextActiviteSecondaireFinal();
  995.         $meta_tags $this->refMetaTagsService->generateMetaPage($activite_secondaire,'activite_secondaire');
  996.         if ($meta_tags) {
  997.             $this->basicSeo->setTitle($meta_tags['title'])
  998.                            ->setDescription($meta_tags['description']);
  999.         }
  1000.    
  1001.         $ref_pages $this->getDoctrine()->getRepository(Post::class)->findPageRefByIdSousActivite($activite_secondaire->getId());
  1002.         $actualites $this->getDoctrine()->getRepository(Post::class)->findPageClientByIdActiviteOrSousActivite($activite_secondaire->getId(),'activite_secondaire');
  1003.         $ref_pages_activites null;
  1004.         if ($activite_secondaire->getActivitePrimaire()) {
  1005.             $ref_pages_activites $this->getDoctrine()->getRepository(Post::class)->findPageRefByIdActivite($activite_secondaire->getActivitePrimaire()->getId());
  1006.         }
  1007.         $parametre $this->functionService->parametreGenerale();
  1008.         $secteurs = [];
  1009.         $all_secteurs $this->getDoctrine()->getRepository(Secteurs::class)->findBy(['actif'=> true]);
  1010.         if ($all_secteurs) {
  1011.             foreach ($all_secteurs as $secteur) {
  1012.                if(in_array($activite_secondaire->getId(),explode(',',$secteur->getActiviteSecondaireIds()))){
  1013.                    $secteurs[] = $secteur;
  1014.                }
  1015.             }
  1016.         }
  1017.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  1018.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  1019.         $schemaOrg = new Graph();
  1020.         $breadcrumb = [];
  1021.         $schema_breadcrumb_items = [];
  1022.         
  1023.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane,'active'=> true];
  1024.         $schema_breadcrumb_items[] = Schema::ListItem()
  1025.                                      ->position(1)
  1026.                                      ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  1027.         $breadcrumb_item 1;
  1028.         if ($activite_secondaire->getActivitePrimaire()) {
  1029.             $breadcrumb_item $breadcrumb_item 1
  1030.             $activite_primaire $activite_secondaire->getActivitePrimaire();
  1031.             $activite_primaire_titre =  $activite_primaire->translate($_locale)->getTitreActivite();
  1032.             $activite_primaire_slug $activite_primaire->translate($_locale)->getLibelleUrl();
  1033.             $title_breadcrumb_activite_primaire =  $activite_primaire->translate($_locale)->getBreadcrumb() ? $activite_primaire->translate($_locale)->getBreadcrumb() : $activite_primaire_titre;
  1034.             $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=>  $activite_primaire_slug], UrlGeneratorInterface::ABSOLUTE_URL),
  1035.                               "name"=> $title_breadcrumb_activite_primaire,'active'=> true];
  1036.             $schema_breadcrumb_items[] = Schema::ListItem()
  1037.                                     ->position($breadcrumb_item)
  1038.                                     ->item(["@id"=> $this->generateUrl('page', ['slug'=>  $activite_primaire_slug], UrlGeneratorInterface::ABSOLUTE_URL),
  1039.                                             "name"=> $title_breadcrumb_activite_primaire]);
  1040.    
  1041.         }
  1042.         $title_breadcrumb_activite_secondaire =  $activite_secondaire->translate($_locale)->getBreadcrumb() ? $activite_secondaire->translate($_locale)->getBreadcrumb() : $activite_secondaire->translate($_locale)->getTitreActiviteSecondaire();
  1043.         $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=>  $activite_secondaire->translate($_locale)->getLibelleUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  1044.                             'name'=> $title_breadcrumb_activite_secondaire,'active'=> false];
  1045.         $schema_breadcrumb_items[] = Schema::ListItem()
  1046.                                     ->position($breadcrumb_item 1)
  1047.                                     ->item(["@id"=> $this->generateUrl('page', ['slug'=>  $activite_secondaire->translate($_locale)->getLibelleUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  1048.                                     "name"=> $title_breadcrumb_activite_secondaire]);
  1049.     
  1050.         $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  1051.         $parametreRef $this->getDoctrine()->getRepository(ParametreRef::class)->findOneBy(['alias'=> 'param_generale']);
  1052.         $template =  $this->render('front/'.$this->theme.'/page_activite_secondaire.html.twig',[
  1053.             'titre'=> $titre,
  1054.             'texte'=> $texte,
  1055.             'titre_activite'=>$titre_activite,
  1056.             'activite_secondaire'=> $activite_secondaire,
  1057.             'parametreRef'=> $parametreRef,
  1058.             'activite_primaire_titre'=> $activite_primaire_titre,
  1059.             'activite_primaire_slug'=> $activite_primaire_slug,
  1060.             'slug'=> $slug,
  1061.             'schemaOrg'=> $schemaOrg,
  1062.             'ref_pages'=> $ref_pages,
  1063.             'ref_pages_activites'=> $ref_pages_activites,
  1064.             'actualites'=> $actualites,
  1065.             'parametre'=> $parametre,
  1066.             'secteurs'=> $secteurs,
  1067.             'breadcrumb'=> $breadcrumb
  1068.         ]);
  1069.         return $template;
  1070.     }
  1071.     public function pageActiviteSecteur($request,$slug,$slug_info){
  1072.         $_locale $request->getLocale();
  1073.         $activite_primaire_titre null;
  1074.         $activite_primaire_slug null;
  1075.         $activite_secondaire_titre null;
  1076.         $activite_secondaire_slug null;
  1077.         $activite_secteur $this->getDoctrine()->getRepository(ListeRef::class)->findActiviteSecteurBySlug($slug);
  1078.         if ($activite_secteur) {
  1079.             if ($activite_secteur->getType() == 'activite_primaire') {
  1080.                 $activite $this->getDoctrine()->getRepository(Activites::class)->findOneBy(['actif'=>true,'id'=>$activite_secteur->getIdActivite()]);
  1081.                 if($activite){
  1082.                     $activite_primaire_titre $activite->translate($_locale)->getTitreActivite();
  1083.                     $activite_primaire_slug $activite->translate($_locale)->getLibelleUrl();
  1084.                 }
  1085.             }else{
  1086.                 $activite_secondaire $this->getDoctrine()->getRepository(ActiviteSecondaire::class)->findOneBy(['actif'=>true,'id'=>$activite_secteur->getIdActivite()]);
  1087.                 if ($activite_secondaire) {
  1088.                     $activite_secondaire_titre $activite_secondaire->translate($_locale)->getTitreActiviteSecondaire();
  1089.                     $activite_secondaire_slug $activite_secondaire->translate($_locale)->getLibelleUrl();
  1090.                 }
  1091.                 if ($activite_secondaire->getActivitePrimaire()) {
  1092.                     $activite_primaire_titre $activite_secondaire->getActivitePrimaire()->translate($_locale)->getTitreActivite();
  1093.                     $activite_primaire_slug $activite_secondaire->getActivitePrimaire()->translate($_locale)->getLibelleUrl();
  1094.                 }
  1095.             }
  1096.         }
  1097.         $meta_tags $this->metaService->generateMetaPage($activite_secteur,'activite_secteur');
  1098.         if ($meta_tags) {
  1099.             $this->basicSeo->setTitle($meta_tags['title'])
  1100.                            ->setDescription($meta_tags['description']);
  1101.         }
  1102.      
  1103.     
  1104.         $template =  $this->render('front/'.$this->theme.'/page_activite_secteur.html.twig',[
  1105.             'activite_secteur'=> $activite_secteur,
  1106.             'slug'=> $slug,
  1107.             'activite_primaire_titre'=> $activite_primaire_titre,
  1108.             'activite_primaire_slug'=> $activite_primaire_slug,
  1109.             'activite_secondaire_titre'=> $activite_secondaire_titre,
  1110.             'activite_secondaire_slug'=> $activite_secondaire_slug,
  1111.         ]);
  1112.         return $template;
  1113.     }
  1114.     public function pageTraking($request,$slug){
  1115.         $schemaOrg = new Graph();
  1116.         $_locale $request->getLocale();
  1117.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  1118.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  1119.         $seo_image '';
  1120.         $url $this->generateUrl('page', ['slug'=> $slug], UrlGeneratorInterface::ABSOLUTE_URL);
  1121.         if ($this->functionService->parametreGenerale()) {
  1122.             if ($this->functionService->parametreGenerale()->getApercuImageLien()) {
  1123.                 $seo_image $baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getApercuImageLien();
  1124.             }
  1125.         }
  1126.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  1127.         $breadcrumb = [];
  1128.         $schema_breadcrumb_items = [];
  1129.         
  1130.         switch ($slug) {
  1131.             case 'contact-envoye':
  1132.                 $title_page_ariane "Contact envoye";
  1133.                 break;
  1134.             case 'contact-envoye-devis':
  1135.                 $title_page_ariane "Contact envoye devis";
  1136.                 break;
  1137.             case 'contact-landing-page':
  1138.                 $title_page_ariane "Contact envoye";
  1139.                 break;
  1140.         }
  1141.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane,'active'=> true];
  1142.         $schema_breadcrumb_items[] = Schema::ListItem()
  1143.                                    ->position(1)
  1144.                                    ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  1145.         
  1146.         $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=> $slug], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_page_ariane,'active'=> false];
  1147.         $schema_breadcrumb_items[] = Schema::ListItem()
  1148.                                     ->position(1)
  1149.                                     ->item(["@id"=> $this->generateUrl('page', ['slug'=> $slug], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_page_ariane]);
  1150.                                    
  1151.         if ($schema_breadcrumb_items) {
  1152.             $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  1153.         }
  1154.         if ($slug == 'contact-envoye') {
  1155.             $template $this->render('front/'.$this->theme.'/form/traking-pages/contact_envoye.html.twig',[
  1156.                 'breadcrumb'=> $breadcrumb,
  1157.                 'title_page'=> $title_page_ariane
  1158.             ]);
  1159.         }
  1160.         if ($slug == 'contact-envoye-devis') {
  1161.             $template $this->render('front/'.$this->theme.'/form/traking-pages/contact_envoye_devis.html.twig',[
  1162.                 'breadcrumb'=> $breadcrumb,
  1163.                 'title_page'=> $title_page_ariane
  1164.             ]);
  1165.         }
  1166.         if ($slug == 'contact-landing-page') {
  1167.             $template $this->render('front/'.$this->theme.'/form/traking-pages/contact_landing_page.html.twig',[
  1168.                 'breadcrumb'=> $breadcrumb,
  1169.                 'title_page'=> $title_page_ariane
  1170.             ]);
  1171.         }
  1172.         if ($this->session->get('traking-page') != true) {
  1173.             throw new NotFoundHttpException('Sorry not existing!');
  1174.         } 
  1175.         
  1176.         $this->session->remove('traking-page');
  1177.         return $template;
  1178.     }
  1179.     /**
  1180.      * @Route("/bons-cadeaux", name="bons_cadeaux",priority="10")
  1181.      */
  1182.     public function PageBonsCadeaux(Request $request)
  1183.     {
  1184.         $_locale $request->getLocale();
  1185.         $module 'bons-cadeaux';
  1186.         $all_galleries_posts = [];
  1187.         $champs_personnalises_posts = [];
  1188.         $posts null;
  1189.     
  1190.         $typePost $this->getDoctrine()->getRepository(TypePost::class)->findSystemName($module);
  1191.         if(!$typePost){
  1192.             throw new NotFoundHttpException('Sorry not existing!');
  1193.         }else{
  1194.             $posts $this->getDoctrine()->getRepository(Post::class)->findAllActivesPostsByType($_locale,$typePost->getId());
  1195.         }
  1196.         $parametreSite $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy([],['id'=> 'DESC']);
  1197.         $parametreRef $this->getDoctrine()->getRepository(ParametreRef::class)->findOneBy(['alias'=> 'param_bon_cadeaux']);
  1198.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  1199.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  1200.         $title_page $parametreRef && $parametreRef->translate($_locale)->getBreadcrumb() ? $parametreRef->translate($_locale)->getBreadcrumb() : $parametreRef->translate($_locale)->getTitreParamRef();
  1201.         if ($parametreRef) {
  1202.             $meta_tags $this->metaService->generateMetaPage($parametreRef,'param_bon_cadeaux');
  1203.             if ($meta_tags) {
  1204.                 $this->basicSeo->setTitle($meta_tags['title'])
  1205.                                ->setDescription($meta_tags['description']);
  1206.             }
  1207.         }
  1208.         if($posts){
  1209.             foreach($posts as $post){
  1210.                 // Galleries posts
  1211.                 $galleries_posts = [];
  1212.                 $galleries_images = [];
  1213.                 $galleries_posts $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$post->getId(),'media');
  1214.                 $galleries_images =  $this->affichageGallerieService->GallerieImages($galleries_posts,$galleries_images);
  1215.                 $all_galleries_posts[] = [
  1216.                     'id' => $post->getId(),
  1217.                     'gallerie' => $galleries_images
  1218.                 ];
  1219.                 // Champs personnalisés
  1220.                 $champsPersonnalisesPost = [];
  1221.                 $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($post);
  1222.                 
  1223.                 if($champsPersonnalisesPost){
  1224.                     $champs_personnalises_posts[] = [
  1225.                         'id_post' => $post->getId(),
  1226.                         'champs_personnalises_post' => $champsPersonnalisesPost
  1227.                     ];
  1228.                 }
  1229.             }
  1230.         }
  1231.         return $this->render('front/'.$this->theme.'/page_bons_cadeaux.html.twig',[
  1232.             'posts'=> $posts,
  1233.             'all_galleries_posts' => $all_galleries_posts,
  1234.             'champs_personnalises_posts' => $champs_personnalises_posts,
  1235.             'parametre' => $parametreSite,
  1236.             'parametreRef'=> $parametreRef,
  1237.             'title_page'=> $title_page,
  1238.             'title_home_ariane' => $title_home_ariane
  1239.         ]);
  1240.     }
  1241.     
  1242.     /**
  1243.      * @Route("/recrutement", name="recrutement",priority="10")
  1244.      */
  1245.     public function PageRecrutement(Request $request)
  1246.     {
  1247.         $_locale $request->getLocale();
  1248.         $module 'recrutement';
  1249.         $all_galleries_posts = [];
  1250.         $champs_personnalises_posts = [];
  1251.         $posts null;
  1252.     
  1253.         $typePost $this->getDoctrine()->getRepository(TypePost::class)->findSystemName($module);
  1254.         if(!$typePost){
  1255.             throw new NotFoundHttpException('Sorry not existing!');
  1256.         }else{
  1257.             $posts $this->getDoctrine()->getRepository(Post::class)->findAllActivesPostsByType($_locale,$typePost->getId());
  1258.         }
  1259.         $parametreSite $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy([],['id'=> 'DESC']);
  1260.         $parametreRef $this->getDoctrine()->getRepository(ParametreRef::class)->findOneBy(['alias'=> 'param_recrutement']);
  1261.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  1262.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  1263.         $title_page $parametreRef && $parametreRef->translate($_locale)->getBreadcrumb() ? $parametreRef->translate($_locale)->getBreadcrumb() : $parametreRef->translate($_locale)->getTitreParamRef();
  1264.         if ($parametreRef) {
  1265.             $meta_tags $this->metaService->generateMetaPage($parametreRef,'param_recrutement');
  1266.             if ($meta_tags) {
  1267.                 $this->basicSeo->setTitle($meta_tags['title'])
  1268.                                ->setDescription($meta_tags['description']);
  1269.             }
  1270.         }
  1271.         if($posts){
  1272.             foreach($posts as $post){
  1273.                 // Champs personnalisés
  1274.                 $champsPersonnalisesPost = [];
  1275.                 $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($post);
  1276.                 
  1277.                 $champs_personnalises_posts[] = [
  1278.                     'id_post' => $post->getId(),
  1279.                     'champs_personnalises_post' => $champsPersonnalisesPost
  1280.                 ];
  1281.             }
  1282.         }
  1283.         return $this->render('front/'.$this->theme.'/page_recrutement.html.twig',[
  1284.             'posts'=> $posts,
  1285.             'champs_personnalises_posts' => $champs_personnalises_posts,
  1286.             'parametre' => $parametreSite,
  1287.             'parametreRef'=> $parametreRef,
  1288.             'title_page'=> $title_page,
  1289.             'title_home_ariane' => $title_home_ariane
  1290.         ]);
  1291.     }
  1292.     function MetaModulePostOrCategory($request,$slug,$slug_info){
  1293.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  1294.         $url $this->generateUrl('page', ['slug'=> $slug], UrlGeneratorInterface::ABSOLUTE_URL);
  1295.         $metaService $this->metaService->meta($slug,$slug_info->getType());
  1296.         $title_seo =  isset($metaService['title'])?$metaService['title']:null;
  1297.         $description_seo = isset($metaService['description'])?$metaService['description']:null;
  1298.         $metacle = isset($metaService['metacle'])?$metaService['metacle']:null;
  1299.         if($title_seo != '' || $description_seo != ''){
  1300.             $this->basicSeo->setTitle($title_seo)
  1301.                         ->setDescription($description_seo)
  1302.                         ->setkeywords($metacle);
  1303.             $this->seo->setTitle($title_seo)
  1304.                     ->setDescription($description_seo)
  1305.                     ->setUrl($url);
  1306.             if ($this->functionService->parametreGenerale()) {
  1307.                 if ($this->functionService->parametreGenerale()->getApercuImageLien()) {
  1308.                     $this->seo->setImage($baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getApercuImageLien());
  1309.                 }
  1310.             }
  1311.         }
  1312.     }
  1313. }