src/Controller/Front/PageCategorieController.php line 138

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\UrlPost;
  7. use App\Entity\Category;
  8. use App\Entity\Language;
  9. use App\Entity\ListeRef;
  10. use App\Entity\MediaCms;
  11. use App\Entity\Secteurs;
  12. use App\Entity\TypePost;
  13. use App\Entity\Activites;
  14. use App\Entity\ListeMenu;
  15. use App\Service\BuildTree;
  16. use App\Entity\CpPostField;
  17. use App\Entity\PostArchive;
  18. use App\Service\RenderBloc;
  19. use Spatie\SchemaOrg\Graph;
  20. use App\Entity\ParametreRef;
  21. use App\Entity\PostCategory;
  22. use App\Service\MetaService;
  23. use Spatie\SchemaOrg\Schema;
  24. use App\Entity\ModelGallerie;
  25. use App\Entity\ParametreSite;
  26. use App\Entity\ReseauSociaux;
  27. use App\Service\MetaClePageRef;
  28. use App\Service\FunctionService;
  29. use App\Service\AffichageGallerieService;
  30. use App\Entity\ActiviteSecondaire;
  31. use App\Entity\CpField;
  32. use App\Entity\ParametrePost;
  33. use App\Service\RefMetaTagsService;
  34. use App\Service\MetaWithoutCategoryService;
  35. use Symfony\Component\HttpFoundation\Request;
  36. use Symfony\Component\HttpFoundation\Response;
  37. use Symfony\Component\Routing\Annotation\Route;
  38. use Symfony\Component\HttpFoundation\JsonResponse;
  39. use Leogout\Bundle\SeoBundle\Seo\Og\OgSeoGenerator;
  40. use Symfony\Component\String\Slugger\SluggerInterface;
  41. use Leogout\Bundle\SeoBundle\Seo\Basic\BasicSeoGenerator;
  42. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  43. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  44. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  45. class PageCategorieController extends AbstractController
  46. {
  47.     public $basicSeo;
  48.     public $seo;
  49.     private $slugger;
  50.     private $projectDir;
  51.     private $metaService;
  52.     private $metaClePageRef;
  53.     private $renderBloc;
  54.     private $buildTree;
  55.     private $functionService;
  56.     private $metaPostService;
  57.     private $theme;
  58.     private $refMetaTagsService;
  59.     private $affichageGallerieService;
  60.     
  61.     public function __construct(string $projectDir,string $theme,
  62.                                 BasicSeoGenerator $basicSeo,
  63.                                 OgSeoGenerator $seo,
  64.                                 RenderBloc $renderBloc,
  65.                                 RefMetaTagsService $refMetaTagsService,
  66.                                 SluggerInterface $slugger,
  67.                                 BuildTree $buildTree,
  68.                                 MetaService $metaService,
  69.                                 MetaWithoutCategoryService $metaPostService,
  70.                                 MetaClePageRef $metaClePageRef,
  71.                                 FunctionService $functionService,
  72.                                 AffichageGallerieService $affichageGallerieService){
  73.         $this->metaService $metaService;
  74.         $this->metaPostService $metaPostService;
  75.         $this->basicSeo $basicSeo;
  76.         $this->seo $seo;
  77.         $this->buildTree $buildTree;
  78.         $this->slugger $slugger;
  79.         $this->metaClePageRef $metaClePageRef;
  80.         $this->functionService $functionService;
  81.         $this->refMetaTagsService $refMetaTagsService;
  82.         $this->renderBloc $renderBloc;
  83.         $this->projectDir $projectDir;
  84.         $this->theme $theme;
  85.         $this->affichageGallerieService $affichageGallerieService;
  86.     }
  87.     /**
  88.      * @Route("/{categorie1}/{categorie2}", name="page_sous_categorie",priority="-2")
  89.      */
  90.     public function PageCategorieN2(Request $request,$categorie1,$categorie2,$page 1){
  91.         $_locale $request->getLocale();
  92.         if($request->query->get('page')){
  93.             $page $request->query->get('page');
  94.         }
  95.         $slug_lang $this->getDoctrine()->getRepository(UrlPost::class)->findLangUrl($categorie1);
  96.         if ($slug_lang['locale'] != $_locale) {
  97.             $request->getSession()->set('_locale'$slug_lang['locale']);
  98.             return $this->redirectToroute('page_sous_categorie',['categorie1'=> $categorie1,'categorie2'=>$categorie2]);
  99.         }
  100.         $categorie $this->getDoctrine()->getRepository(Category::class)->findCategoryBySlug($categorie1);
  101.         $sous_categorie $this->getDoctrine()->getRepository(Category::class)->findCategoryBySlug($categorie2);
  102.         $post $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($categorie2);
  103.         if(empty($categorie) || (empty($sous_categorie) && empty($post))){
  104.             throw new NotFoundHttpException('Sorry not existing!');
  105.         }
  106.         if ($sous_categorie != null) {
  107.             $this->MetaModulePostOrCategory($request,$categorie2,'Sous-categorie');
  108.             $template  $this->PageSousCategorie($request,$categorie,$sous_categorie,$page);
  109.         }else{
  110.             if ($post->getTypePost()->translate($_locale)->getSystemName() != 'produits') {
  111.                 return $this->redirectToRoute('page',['slug'=> $categorie2]);
  112.             }
  113.             
  114.             $this->MetaModulePostOrCategory($request,$categorie2,'Post');
  115.             $template $this->PageProduit($request,$post,$categorie);
  116.         }
  117.         return $template;
  118.     }
  119.     /**
  120.      * @Route("/{categorie1}/{categorie2}/{categorie3}", name="page_sous_sous_categorie",priority="-2")
  121.      */
  122.     public function PageCategorieN3(Request $request,$categorie1,$categorie2,$categorie3,$page 1){
  123.         $_locale $request->getLocale();
  124.         if($request->query->get('page')){
  125.             $page $request->query->get('page');
  126.         }
  127.         $slug_lang $this->getDoctrine()->getRepository(UrlPost::class)->findLangUrl($categorie1);
  128.         if ($slug_lang['locale'] != $_locale) {
  129.             $request->getSession()->set('_locale'$slug_lang['locale']);
  130.             return $this->redirectToroute('page_sous_sous_categorie',['categorie1'=> $categorie1,'categorie2'=>$categorie2,'categorie3'=>$categorie3]);
  131.         }
  132.         $categorie $this->getDoctrine()->getRepository(Category::class)->findCategoryBySlug($categorie1);
  133.         $sous_categorie $this->getDoctrine()->getRepository(Category::class)->findCategoryBySlug($categorie2);
  134.         $sous_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findCategoryBySlug($categorie3);
  135.         $post $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($categorie3);
  136.         if((empty($categorie) && empty($sous_categorie)) || (empty($sous_sous_categorie) && empty($post))){
  137.             throw new NotFoundHttpException('Sorry not existing!');
  138.         }
  139.         if ($sous_sous_categorie != null) {
  140.             $this->MetaModulePostOrCategory($request,$categorie3,'Sous-sous-categorie');
  141.             $template  $this->PageSousSousCategorie($request,$categorie,$sous_categorie,$sous_sous_categorie,$page);
  142.         }else{
  143.             $this->MetaModulePostOrCategory($request,$categorie3,'Post');
  144.             $template $this->PageProduit($request,$post,$categorie,$sous_categorie,$sous_sous_categorie);
  145.         }
  146.         return $template;
  147.     }
  148.     /**
  149.      * @Route("/{categorie1}/{categorie2}/{categorie3}/{slug_produit}", name="page_produit",priority="-2")
  150.      */
  151.     public function PageCategorieProduit(Request $request,$categorie1,$categorie2,$categorie3,$slug_produit,$page 1){
  152.         $_locale $request->getLocale();
  153.         if($request->query->get('page')){
  154.             $page $request->query->get('page');
  155.         }
  156.         $slug_lang $this->getDoctrine()->getRepository(UrlPost::class)->findLangUrl($categorie1);
  157.         if ($slug_lang['locale'] != $_locale) {
  158.             $request->getSession()->set('_locale'$slug_lang['locale']);
  159.             return $this->redirectToroute('page_produit',[
  160.                 'categorie1'=> $categorie1,'categorie2'=>$categorie2,
  161.                 'categorie3'=>$categorie3,'slug_produit' => $slug_produit]);
  162.         }
  163.         $categorie $this->getDoctrine()->getRepository(Category::class)->findCategoryBySlug($categorie1);
  164.         $sous_categorie $this->getDoctrine()->getRepository(Category::class)->findCategoryBySlug($categorie2);
  165.         $sous_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findCategoryBySlug($categorie3);
  166.         $post $this->getDoctrine()->getRepository(Post::class)->findPostBySlug($slug_produit);
  167.         if(empty($categorie) && empty($sous_categorie) && empty($sous_sous_categorie) && empty($post)){
  168.             throw new NotFoundHttpException('Sorry not existing!');
  169.         }
  170.         $this->MetaModulePostOrCategory($request,$slug_produit,'Post');
  171.         $template $this->PageProduit($request,$post,$categorie,$sous_categorie,$sous_sous_categorie,$post);
  172.         return $template;
  173.     }
  174.     public function PageSousCategorie($request,$categorie,$sous_categorie,$page){
  175.         $module 'category';
  176.         $resultats = [];
  177.         $schemaOrg = new Graph();
  178.         $_locale $request->getLocale();
  179.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  180.         $template $sous_categorie->getTypeAffichageHome();
  181.         $bloc_categorie $this->renderBloc->RenderBloc($sous_categorie,$schemaOrg,'categorie');
  182.         $show_filter_categorie $categorie->getTypePost()->getFilterCategorie();
  183.         // Galleries
  184.         $galleries_images = [];
  185.         $modele_galerie_choisie $sous_categorie->getModeleGallerie() ? $sous_categorie->getModeleGallerie()->getId() : 1;
  186.         $modele_gallerie $this->getDoctrine()->getRepository(ModelGallerie::class)->findById($modele_galerie_choisie);
  187.         $galleries $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$sous_categorie->getId(),'media');
  188.         $galleries_images =  $this->affichageGallerieService->GallerieImages($galleries,$galleries_images);
  189.         $template_model_galerie $modele_gallerie[0]->getTwig();
  190.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  191.         $meta_robots $sous_categorie->getMetaRobots();
  192.         $schema_breadcrumb_items = [];
  193.         $breadcrumb = [];
  194.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),'name'=> $title_home_ariane,'active'=> true];
  195.         $schema_breadcrumb_items[] = Schema::ListItem()->position(1)
  196.                                      ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  197.         $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=> $categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),'name'=> $categorie->translate($_locale)->getTitreCategorie(),'active'=> true];
  198.         $schema_breadcrumb_items[] = Schema::ListItem()->position(2)
  199.                                      ->item(["@id"=> $this->generateUrl('page', ['slug'=> $categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $categorie->translate($_locale)->getTitreCategorie()]);
  200.         $breadcrumb [] = ['url'=> $this->generateUrl('page_sous_categorie', ['categorie1'=> $categorie->translate($_locale)->getSlugUrl(),'categorie2'=> $sous_categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),'name'=> $sous_categorie->translate($_locale)->getTitreCategorie(),'active'=> false];
  201.         $schema_breadcrumb_items[] = Schema::ListItem()->position(3)
  202.                                      ->item(["@id"=> $this->generateUrl('page_sous_categorie', ['categorie1'=> $categorie->translate($_locale)->getSlugUrl(),'categorie2'=> $sous_categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $sous_categorie->translate($_locale)->getTitreCategorie()]);
  203.         if ($schema_breadcrumb_items) {
  204.             $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  205.         }
  206.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  207.         $schemaOrg->add(Schema::Article()
  208.                     ->headline($sous_categorie->translate($_locale)->getTitreCategorie())
  209.                     ->datePublished($sous_categorie->getCreatedAt())
  210.                     ->dateModified($sous_categorie->getUpdatedAt())
  211.                     ->image($sous_categorie->getImage()!= null?$baseurl.$sous_categorie->getImage():'')
  212.                     ->publisher(Schema::Organization()
  213.                     ->name($this->functionService->parametreGenerale()?$this->functionService->parametreGenerale()->translate($_locale)->getTitre():'')
  214.                     ->logo($this->functionService->parametreGenerale()?$baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getImage():''))
  215.                     ->mainEntityOfPage(Schema::WebPage()->url($this->generateUrl('page_sous_categorie', ['categorie1'=> $categorie->translate($_locale)->getSlugUrl(),'categorie2'=> $sous_categorie->translate($_locale)->getSlugUrl()], 
  216.                     UrlGeneratorInterface::ABSOLUTE_URL)))
  217.                   );
  218.         $docs $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$categorie->getId(),'doc');
  219.         $parametre $this->functionService->parametreGenerale();
  220.         $categories_tree = [];
  221.         $categories_principal =  $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> 0,'TypePost'=> $categorie->getTypePost()]);
  222.         if ($categories_principal) {
  223.             foreach ($categories_principal as $value) {
  224.                 $data_slug_sous_categorie = [];
  225.                 $tree_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> $value->getId()],['position'=>'ASC']);
  226.                 if($tree_sous_categorie){
  227.                     foreach ($tree_sous_categorie as $sous_categorie_items) {
  228.                         $data_slug_sous_sous_categorie = [];
  229.                         $tree_sous_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> $sous_categorie_items->getId()],['position'=>'ASC']);
  230.                         if ($tree_sous_sous_categorie) {
  231.                             foreach ($tree_sous_sous_categorie as  $sous_sous_categorie_items) {
  232.                                 $data_slug_sous_sous_categorie[] = [
  233.                                 'id'=> $sous_sous_categorie_items->getId(),
  234.                                 'titre'=> $sous_sous_categorie_items->translate($_locale)->getTitreCategorie(),
  235.                                 'slug'=> $sous_sous_categorie_items->translate($_locale)->getSlugUrl()];
  236.                             }
  237.                         }
  238.                         $data_slug_sous_categorie[] = ['id'=> $sous_categorie_items->getId(),
  239.                                                        'titre'=> $sous_categorie_items->translate($_locale)->getTitreCategorie(),
  240.                                                        'slug'=> $sous_categorie_items->translate($_locale)->getSlugUrl(),
  241.                                                        'sous_sous_categories'=> $data_slug_sous_sous_categorie,
  242.                                                       ];
  243.                     }
  244.                 }
  245.                 $categories_tree[] = ['id'=> $value->getId(),
  246.                                       'titre'=> $value->translate($_locale)->getTitreCategorie(),
  247.                                       'slug'=> $value->translate($_locale)->getSlugUrl(),
  248.                                       'sous_categories'=> $data_slug_sous_categorie,
  249.                                     ];
  250.             }
  251.         }
  252.         $parametrePost $this->getDoctrine()->getRepository(ParametrePost::class)->findOneBy(['TypePost'=> $categorie->getTypePost()]);
  253.         if($parametrePost->getShowCategories()) {
  254.             $sous_s_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> '0','sousParent'=> $sous_categorie->getId()],['position'=>'ASC']);
  255.             if ($sous_s_categorie) {
  256.                 $posts $this->getDoctrine()->getRepository(Category::class)->findSousCategorie($sous_categorie,$page);
  257.                 $postItems $sous_categorie->getPagination() == true?$posts->getResults():$sous_s_categorie;
  258.                 foreach ($postItems as $value) {
  259.                     $resultats[] = [ 'id'=> $value->getId(),
  260.                                      'slug'=> $value->translate($_locale)->getSlugUrl(),
  261.                                      'slug_categorie_parent'=> $categorie->translate($_locale)->getSlugUrl(),
  262.                                      'slug_sous_categorie'=> $sous_categorie->translate($_locale)->getSlugUrl(),
  263.                                      'titre'=> $value->translate($_locale)->getTitreCategorie(),
  264.                                      'title_affichage'=> null,
  265.                                      'content'=> $value->translate($_locale)->getTexteCategorie(),
  266.                                      'chapeau'=> $value->translate($_locale)->getChapeauCategorie(),
  267.                                      'image'=> $value->getImage(),
  268.                                      'typelien'=> $value->getTypeLien(),
  269.                                      'titrelien'=> $value->getTitreLien(),
  270.                                      'telephone'=> $value->getTelephone(),
  271.                                      'lieninterne'=> $value->getLienInterne(),
  272.                                      'lienexterne'=> $value->getLienExterne(),
  273.                                     ];
  274.                 }
  275.             }else{
  276.                 $posts $this->getDoctrine()->getRepository(Post::class)->findPostBySpecifiqueCategory($sous_categorie,$page,$this->functionService->findRelatedIdsByCategorie($categories_tree,$sous_categorie->getId(),'2'));
  277.                 $postItems $categorie->getPagination() == true ?$posts->getResults():$posts;
  278.                 if ($postItems) {
  279.                     foreach ($postItems as $value) {
  280.     
  281.                         $galleries_first_image $this->affichageGallerieService->FirstGallerieImagePost($value);
  282.                         // Champs personnalisés
  283.                         $champsPersonnalisesPost = [];
  284.                         $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($value);
  285.     
  286.                         $resultats[] = [ 'id'=> $value->getId(),
  287.                                          'slug'=> $value->getSlug(),
  288.                                          'titre'=> $value->getTitle(),
  289.                                          'title_affichage'=> $value->getTitleAffichage(),
  290.                                          'slug_categorie_parent'=> $categorie->translate($_locale)->getSlugUrl(),
  291.                                          'slug_sous_categorie'=> $sous_categorie->translate($_locale)->getSlugUrl(),
  292.                                          'content'=> $value->getContent(),
  293.                                          'chapeau'=> $value->getSummary(),
  294.                                          'image'=> $value->getImage(),
  295.                                          'image_couverture'=> $value->getImageCouverture(),
  296.                                          'galleries_first_image'=> $galleries_first_image,
  297.                                          'typelien'=> $value->getTypeLien(),
  298.                                          'titrelien'=> $value->getTitreLien(),
  299.                                          'telephone'=> $value->getTelephone(),
  300.                                          'lieninterne'=> $value->getLienInterne(),
  301.                                          'lienexterne'=> $value->getLienExterne(),
  302.                                          'prixproduit'=> $value->getPrixProduit(),
  303.                                          'referance'=> $value->getReferanceProduit(),
  304.                                          'champsPersonnalisesPost' => $champsPersonnalisesPost];
  305.                     }
  306.                 }
  307.             }
  308.         }else {
  309.             $posts $this->getDoctrine()->getRepository(Post::class)->findPostBySpecifiqueCategory($sous_categorie,$page,$this->functionService->findRelatedIdsByCategorie($categories_tree,$sous_categorie->getId(),'2'));
  310.             $postItems $categorie->getPagination() == true ?$posts->getResults():$posts;
  311.             if ($postItems) {
  312.                 foreach ($postItems as $value) {
  313.                     $galleries_first_image $this->affichageGallerieService->FirstGallerieImagePost($value);
  314.                     // Champs personnalisés
  315.                     $champsPersonnalisesPost = [];
  316.                     $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($value);
  317.                     $resultats[] = [ 'id'=> $value->getId(),
  318.                                      'slug'=> $value->getSlug(),
  319.                                      'titre'=> $value->getTitle(),
  320.                                      'title_affichage'=> $value->getTitleAffichage(),
  321.                                      'slug_categorie_parent'=> $categorie->translate($_locale)->getSlugUrl(),
  322.                                      'slug_sous_categorie'=> $sous_categorie->translate($_locale)->getSlugUrl(),
  323.                                      'content'=> $value->getContent(),
  324.                                      'chapeau'=> $value->getSummary(),
  325.                                      'image'=> $value->getImage(),
  326.                                      'image_couverture'=> $value->getImageCouverture(),
  327.                                      'galleries_first_image'=> $galleries_first_image,
  328.                                      'typelien'=> $value->getTypeLien(),
  329.                                      'titrelien'=> $value->getTitreLien(),
  330.                                      'telephone'=> $value->getTelephone(),
  331.                                      'lieninterne'=> $value->getLienInterne(),
  332.                                      'lienexterne'=> $value->getLienExterne(),
  333.                                      'prixproduit'=> $value->getPrixProduit(),
  334.                                      'referance'=> $value->getReferanceProduit(),
  335.                                      'champsPersonnalisesPost' => $champsPersonnalisesPost];
  336.                 }
  337.             }
  338.         }
  339.         return $this->render('front/'.$this->theme.'/produits/page_sous_categorie.html.twig',[
  340.             'template'=> $template,
  341.             'categories_tree'=> $categories_tree,
  342.             'title_home_ariane' => $title_home_ariane,
  343.             'categorie'=> $categorie,
  344.             'sous_categorie'=> $sous_categorie,
  345.             'resultats'=> $resultats,
  346.             'blocs'=> $bloc_categorie,
  347.             'show_filter_categorie'=> $show_filter_categorie,
  348.             'posts'=> $posts,
  349.             'meta_robots'=> $meta_robots,
  350.             'pagination'=> $sous_categorie->getPagination(),
  351.             'schemaOrg'=> $schemaOrg,
  352.             'galleries'=> $galleries_images,
  353.             'docs'=> $docs,
  354.             'breadcrumb'=> $breadcrumb,
  355.             'parametre'=> $parametre,
  356.             'modele_galerie' => $modele_gallerie,
  357.             'template_model_gallerie' => $template_model_galerie,
  358.         ]);
  359.     }
  360.     public function PageSousSousCategorie($request,$categorie,$sous_categorie,$sous_sous_categorie,$page){
  361.         $module 'category';
  362.         $resultats = [];
  363.         $schemaOrg = new Graph();
  364.         $_locale $request->getLocale();
  365.      
  366.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  367.         $template $sous_categorie->getTypeAffichageHome();
  368.         $bloc_categorie $this->renderBloc->RenderBloc($sous_sous_categorie,$schemaOrg,'categorie');
  369.         $show_filter_categorie $categorie->getTypePost()->getFilterCategorie();
  370.         // Galleries
  371.         $galleries_images = [];
  372.         $modele_galerie_choisie $sous_sous_categorie->getModeleGallerie() ? $sous_sous_categorie->getModeleGallerie()->getId() : 1;
  373.         $modele_gallerie $this->getDoctrine()->getRepository(ModelGallerie::class)->findById($modele_galerie_choisie);
  374.         $galleries $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$sous_sous_categorie->getId(),'media');
  375.         $galleries_images =  $this->affichageGallerieService->GallerieImages($galleries,$galleries_images);
  376.         $template_model_galerie $modele_gallerie[0]->getTwig();
  377.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  378.         $meta_robots $sous_categorie->getMetaRobots();
  379.         $schema_breadcrumb_items = [];
  380.         $breadcrumb = [];
  381.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),'name'=> $title_home_ariane,'active'=> true];
  382.         $schema_breadcrumb_items[] = Schema::ListItem()->position(1)
  383.                                      ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  384.         $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=> $categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),'name'=> $categorie->translate($_locale)->getTitreCategorie(),'active'=> true];
  385.         $schema_breadcrumb_items[] = Schema::ListItem()->position(2)
  386.                                      ->item(["@id"=> $this->generateUrl('page', ['slug'=> $categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $categorie->translate($_locale)->getTitreCategorie()]);
  387.         $breadcrumb [] = ['url'=> $this->generateUrl('page_sous_categorie', ['categorie1'=> $categorie->translate($_locale)->getSlugUrl(),'categorie2'=> $sous_categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),'name'=> $sous_categorie->translate($_locale)->getTitreCategorie(),'active'=> true];
  388.         $schema_breadcrumb_items[] = Schema::ListItem()->position(3)
  389.                                      ->item(["@id"=> $this->generateUrl('page_sous_categorie', ['categorie1'=> $categorie->translate($_locale)->getSlugUrl(),'categorie2'=> $sous_categorie->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $sous_categorie->translate($_locale)->getTitreCategorie()]);
  390.         $breadcrumb [] = ['url'=> $this->generateUrl('page_sous_sous_categorie', [
  391.          'categorie1'=> $categorie->translate($_locale)->getSlugUrl(),
  392.          'categorie2'=> $sous_categorie->translate($_locale)->getSlugUrl(),
  393.          'categorie3'=> $sous_sous_categorie->translate($_locale)->getSlugUrl(),
  394.         ], UrlGeneratorInterface::ABSOLUTE_URL),'name'=> $sous_sous_categorie->translate($_locale)->getTitreCategorie(),'active'=> false];
  395.         $schema_breadcrumb_items[] = Schema::ListItem()->position(4)
  396.                                     ->item(["@id"=> $this->generateUrl('page_sous_sous_categorie', [
  397.                                         'categorie1'=> $categorie->translate($_locale)->getSlugUrl(),
  398.                                         'categorie2'=> $sous_categorie->translate($_locale)->getSlugUrl(),
  399.                                         'categorie3'=> $sous_sous_categorie->translate($_locale)->getSlugUrl(),
  400.                                     ], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $sous_sous_categorie->translate($_locale)->getTitreCategorie()]);
  401.         if ($schema_breadcrumb_items) {
  402.             $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  403.         }
  404.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  405.         $schemaOrg->add(Schema::Article()
  406.                     ->headline($sous_sous_categorie->translate($_locale)->getTitreCategorie())
  407.                     ->datePublished($sous_sous_categorie->getCreatedAt())
  408.                     ->dateModified($sous_sous_categorie->getUpdatedAt())
  409.                     ->image($sous_sous_categorie->getImage()!= null?$baseurl.$sous_sous_categorie->getImage():'')
  410.                     ->publisher(Schema::Organization()
  411.                     ->name($this->functionService->parametreGenerale()?$this->functionService->parametreGenerale()->translate($_locale)->getTitre():'')
  412.                     ->logo($this->functionService->parametreGenerale()?$baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getImage():''))
  413.                     ->mainEntityOfPage(Schema::WebPage()->url($this->generateUrl('page_sous_sous_categorie', [
  414.                         'categorie1'=> $categorie->translate($_locale)->getSlugUrl(),
  415.                         'categorie2'=> $sous_categorie->translate($_locale)->getSlugUrl(),
  416.                         'categorie3'=> $sous_sous_categorie->translate($_locale)->getSlugUrl()
  417.                     ], UrlGeneratorInterface::ABSOLUTE_URL)))
  418.                   );
  419.         $docs $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$sous_sous_categorie->getId(),'doc');
  420.         $parametre $this->functionService->parametreGenerale();
  421.     
  422.         $categories_tree = [];
  423.         $categories_principal =  $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> 0,'TypePost'=> $categorie->getTypePost()],['position'=> 'ASC']);
  424.         if ($categories_principal) {
  425.             foreach ($categories_principal as $value) {
  426.                 $data_slug_sous_categorie = [];
  427.                 $tree_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> $value->getId()],['position'=>'ASC']);
  428.                 if($tree_sous_categorie){
  429.                     foreach ($tree_sous_categorie as $sous_categorie_items) {
  430.                         $data_slug_sous_sous_categorie = [];
  431.                         $tree_sous_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> $sous_categorie_items->getId()],['position'=>'ASC']);
  432.                         if ($tree_sous_sous_categorie) {
  433.                             foreach ($tree_sous_sous_categorie as  $sous_sous_categorie_items) {
  434.                                 $data_slug_sous_sous_categorie[] = [
  435.                                 'id'=> $sous_sous_categorie_items->getId(),
  436.                                 'titre'=> $sous_sous_categorie_items->translate($_locale)->getTitreCategorie(),
  437.                                 'slug'=> $sous_sous_categorie_items->translate($_locale)->getSlugUrl()];
  438.                             }
  439.                         }
  440.                         $data_slug_sous_categorie[] = ['id'=> $sous_categorie_items->getId(),
  441.                                                        'titre'=> $sous_categorie_items->translate($_locale)->getTitreCategorie(),
  442.                                                        'slug'=> $sous_categorie_items->translate($_locale)->getSlugUrl(),
  443.                                                        'sous_sous_categories'=> $data_slug_sous_sous_categorie,
  444.                                                       ];
  445.                     }
  446.                 }
  447.                 $categories_tree[] = ['id'=> $value->getId(),
  448.                                       'titre'=> $value->translate($_locale)->getTitreCategorie(),
  449.                                       'slug'=> $value->translate($_locale)->getSlugUrl(),
  450.                                       'sous_categories'=> $data_slug_sous_categorie,
  451.                                     ];
  452.             }
  453.         }
  454.         if ($sous_sous_categorie->getPagination() == true) {
  455.             $posts $this->getDoctrine()->getRepository(Post::class)->findPostBySpecifiqueCategory($sous_sous_categorie,$page,$this->functionService->findRelatedIdsByCategorie($categories_tree,$sous_sous_categorie->getId(),'3'));
  456.             if($posts->getResults()){
  457.                 foreach ($posts->getResults() as $value) {
  458.                     $galleries_first_image $this->affichageGallerieService->FirstGallerieImagePost($value);
  459.                     $champsPersonnalisesPost = [];
  460.                     $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($value);
  461.                     $resultats[] = [ 'id'=> $value->getId(),
  462.                                      'slug'=> $value->getSlug(),
  463.                                      'titre'=> $value->getTitle(),
  464.                                      'title_affichage'=> $value->getTitleAffichage(),
  465.                                      'slug_categorie_parent'=> $categorie->translate($_locale)->getSlugUrl(),
  466.                                      'slug_sous_categorie'=> $sous_categorie->translate($_locale)->getSlugUrl(),
  467.                                      'slug_sous_sous_categorie'=> $sous_sous_categorie->translate($_locale)->getSlugUrl(),
  468.                                      'content'=> $value->getContent(),
  469.                                      'chapeau'=> $value->getSummary(),
  470.                                      'image'=> $value->getImage(),
  471.                                      'typelien'=> $value->getTypeLien(),
  472.                                      'titrelien'=> $value->getTitreLien(),
  473.                                      'telephone'=> $value->getTelephone(),
  474.                                      'lieninterne'=> $value->getLienInterne(),
  475.                                      'lienexterne'=> $value->getLienExterne(),
  476.                                      'prixproduit'=> $value->getPrixProduit(),
  477.                                      'referance'=> $value->getReferanceProduit(),
  478.                                      'galleries_first_image'=> $galleries_first_image,
  479.                                      'champsPersonnalisesPost' => $champsPersonnalisesPost
  480.                                     ];
  481.                 }
  482.             }
  483.         }else{
  484.             $posts $this->getDoctrine()->getRepository(Post::class)->findPostBySpecifiqueCategory($sous_sous_categorie,$page,$this->functionService->findRelatedIdsByCategorie($categories_tree,$sous_sous_categorie->getId(),'3'));
  485.             if($posts){
  486.                 foreach ($posts as $value) {
  487.                     $galleries_first_image $this->affichageGallerieService->FirstGallerieImagePost($value);
  488.                     $champsPersonnalisesPost = [];
  489.                     $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($value);
  490.                     $resultats[] = [ 'id'=> $value->getId(),
  491.                                      'slug'=> $value->getSlug(),
  492.                                      'titre'=> $value->getTitle(),
  493.                                      'title_affichage'=> $value->getTitleAffichage(),
  494.                                      'slug_categorie_parent'=> $categorie->translate($_locale)->getSlugUrl(),
  495.                                      'slug_sous_categorie'=> $sous_categorie->translate($_locale)->getSlugUrl(),
  496.                                      'slug_sous_sous_categorie'=> $sous_sous_categorie->translate($_locale)->getSlugUrl(),
  497.                                      'content'=> $value->getContent(),
  498.                                      'chapeau'=> $value->getSummary(),
  499.                                      'image'=> $value->getImage(),
  500.                                      'typelien'=> $value->getTypeLien(),
  501.                                      'titrelien'=> $value->getTitreLien(),
  502.                                      'telephone'=> $value->getTelephone(),
  503.                                      'lieninterne'=> $value->getLienInterne(),
  504.                                      'lienexterne'=> $value->getLienExterne(),
  505.                                      'prixproduit'=> $value->getPrixProduit(),
  506.                                      'referance'=> $value->getReferanceProduit(),
  507.                                      'galleries_first_image'=> $galleries_first_image,
  508.                                      'champsPersonnalisesPost' => $champsPersonnalisesPost
  509.                                     ];
  510.                 }
  511.             }
  512.         }
  513.         return $this->render('front/'.$this->theme.'/produits/page_sous_sous_categorie.html.twig',[
  514.             'template'=> $template,
  515.             'categories_tree'=> $categories_tree,
  516.             'title_home_ariane' => $title_home_ariane,
  517.             'categorie'=> $categorie,
  518.             'sous_categorie'=> $sous_categorie,
  519.             'sous_sous_categorie'=> $sous_sous_categorie,
  520.             'show_filter_categorie'=> $show_filter_categorie,
  521.             'resultats'=> $resultats,
  522.             'blocs'=> $bloc_categorie,
  523.             'posts'=> $posts,
  524.             'meta_robots'=> $meta_robots,
  525.             'pagination'=> $sous_sous_categorie->getPagination(),
  526.             'schemaOrg'=> $schemaOrg,
  527.             'galleries'=> $galleries_images,
  528.             'docs'=> $docs,
  529.             'breadcrumb'=> $breadcrumb,
  530.             'parametre'=> $parametre,
  531.             'modele_galerie' => $modele_gallerie,
  532.             'template_model_gallerie' => $template_model_galerie,
  533.         ]);
  534.     }
  535.     public function PageProduit($request,$post,$categorie1 null,$categorie2 null$categorie3 null){
  536.         $schemaOrg = new Graph();
  537.         $_locale $request->getLocale();
  538.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  539.         $modele_galerie_choisie $post->getModeleGallerie() ? $post->getModeleGallerie()->getId() : 1;
  540.         $modele_gallerie $this->getDoctrine()->getRepository(ModelGallerie::class)->findById($modele_galerie_choisie);
  541.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  542.         $seo_image '';
  543.         $type_post $post->getTypePost();
  544.         $show_filter_categorie $type_post->getFilterCategorie();
  545.         $parametrePost $this->getDoctrine()->getRepository(ParametrePost::class)->findOneBy(['TypePost'=> $type_post]);
  546.         if ($this->functionService->parametreGenerale()) {
  547.             if ($this->functionService->parametreGenerale()->getApercuImageLien()) {
  548.                 $seo_image $baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getApercuImageLien();
  549.             }
  550.         }
  551.         $galleries_images = [];
  552.         $bloc_post $this->renderBloc->RenderBloc($post,$schemaOrg);
  553.         $module $post->getTypePost()->getSystemName();
  554.         $galleries $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$post->getId(),'media');
  555.         // Debut Ajout image produit dans la gallerie si type gallerie est 5
  556.         if($modele_galerie_choisie == 5){
  557.             $image_post $post->getImage();
  558.             $chemin_image dirname($image_post);
  559.             $cdn_path '';
  560.             $extension_file pathinfo($image_postPATHINFO_EXTENSION);
  561.             $new_galleries_images = ['id'=> "1",
  562.                                      'path'=> '',
  563.                                      'lienexterne' => "",
  564.                                      'titre'=> $post->translate($_locale)->getTitle(),
  565.                                      'description'=> "",
  566.                                      'extension_file' => $extension_file
  567.                                     ];
  568.             if($extension_file != 'mp4'){
  569.                 // On récupère le nom de fichier sans son extension
  570.                 $nom_sans_extension pathinfo($image_postPATHINFO_FILENAME);
  571.                 // On modifie l'extension du fichier
  572.                 $nouvelle_extension 'webp';
  573.                 $nouveau_nom_fichier $nom_sans_extension '.' $nouvelle_extension;
  574.     
  575.                 if (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') === false) {
  576.                     $new_galleries_images['path'] = str_replace("files/",$cdn_path."thumbs/files800/",$image_post);
  577.                 }else{
  578.                     $new_galleries_images['path'] = str_replace("files/",$cdn_path."thumbs/files800/",$chemin_image."/".$nouveau_nom_fichier);
  579.                 }
  580.             }else{
  581.                 $new_galleries_images['path'] = str_replace("files/",$cdn_path."thumbs/files800/",$image_post);
  582.             }
  583.             
  584.             $galleries_images[] = $new_galleries_images;
  585.         }
  586.         // Fin Ajout image produit dans la gallerie si type gallerie est 5
  587.         
  588.         $galleries_images =  $this->affichageGallerieService->GallerieImages($galleries,$galleries_images);
  589.         $docs $this->getDoctrine()->getRepository(MediaCms::class)->findFileByModule($module,$post->getId(),'doc');
  590.         $meta_robots $post->getMetaRobots();
  591.         $custom_schemaOrg null;
  592.         if ($post->translate($_locale)->getSchema() != '') {
  593.             $custom_schemaOrg $post->translate($_locale)->getSchema();
  594.         }
  595.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  596.         $breadcrumb_item 1;
  597.         $breadcrumb = [];
  598.         $schema_breadcrumb_items = [];
  599.         $title_post_ariane $post->translate($_locale)->getBreadcrumb() ? $post->translate($_locale)->getBreadcrumb() : $post->translate($_locale)->getTitle();
  600.         $title_post_ariane strip_tags($title_post_ariane);
  601.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane,'active'=> true];
  602.         $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(
  603.             ["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  604.         if ($categorie1 != null  && $categorie2 == null && $categorie3 == null) {
  605.             $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=> $categorie1->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  606.                               'name'=> $categorie1->translate($_locale)->getTitreCategorie(),'active'=> true];
  607.             $breadcrumb_item $breadcrumb_item +1;
  608.             $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(["@id"=> $this->generateUrl('page'
  609.                                         ['slug'=> $categorie1->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  610.                                         "name"=> $categorie1->translate($_locale)->getTitreCategorie()]);
  611.             $breadcrumb_item $breadcrumb_item +1;
  612.             $url $this->generateUrl('page_sous_categorie', ['categorie1'=> $categorie1->translate($_locale)->getSlugUrl(),
  613.                                       'categorie2'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  614.             $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(["@id"=> $url,"name"=> $title_post_ariane]);
  615.             $breadcrumb [] = ['url'=> $url,"name"=> $title_post_ariane,'active'=> false];
  616.         }elseif($categorie1 != null  && $categorie2 != null && $categorie3 == null){
  617.             // categorie 1
  618.             $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=> $categorie1->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  619.                               'name'=> $categorie1->translate($_locale)->getTitreCategorie(),'active'=> true];
  620.             $breadcrumb_item $breadcrumb_item +1;
  621.             $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(["@id"=> $this->generateUrl('page'
  622.                                         ["slug"=> $categorie1->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  623.                                          "name"=> $categorie1->translate($_locale)->getTitreCategorie()]);
  624.             // categorie 2
  625.             $breadcrumb [] = ['url'=> $this->generateUrl('page_sous_categorie', ['categorie1'=> $categorie1->translate($_locale)->getSlugUrl(),
  626.             'categorie2'=> $categorie2->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  627.             'name'=> $categorie2->translate($_locale)->getTitreCategorie(),'active'=> true];
  628.             $breadcrumb_item $breadcrumb_item +1;
  629.             $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(["@id"=> $this->generateUrl('page_sous_categorie'
  630.             ['categorie1'=> $categorie1->translate($_locale)->getSlugUrl(),'categorie2'=> $categorie2->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  631.             "name"=> $categorie2->translate($_locale)->getTitreCategorie()]);
  632.             $breadcrumb_item $breadcrumb_item 1;
  633.             $url $this->generateUrl('page_sous_sous_categorie', ['categorie1'=> $categorie1->translate($_locale)->getSlugUrl(),
  634.                         'categorie2'=> $categorie2->translate($_locale)->getSlugUrl(),
  635.                         'categorie3'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  636.             $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(["@id"=> $url,"name"=> $title_post_ariane]);
  637.             $breadcrumb [] = ['url'=> $url,"name"=> $title_post_ariane,'active'=> false];
  638.         }elseif($categorie1 != null  && $categorie2 != null && $categorie3 != null){
  639.             // categorie 1
  640.             $breadcrumb [] = ['url'=> $this->generateUrl('page', ['slug'=> $categorie1->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  641.                               'name'=> $categorie1->translate($_locale)->getTitreCategorie(),'active'=> true];
  642.             $breadcrumb_item $breadcrumb_item 1;
  643.             $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(["@id"=> $this->generateUrl('page'
  644.                                         ["slug"=> $categorie1->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  645.                                          "name"=> $categorie1->translate($_locale)->getTitreCategorie()]);
  646.             // categorie 2
  647.             $breadcrumb [] = ['url'=> $this->generateUrl('page_sous_categorie', ['categorie1'=> $categorie1->translate($_locale)->getSlugUrl(),
  648.             'categorie2'=> $categorie2->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  649.             'name'=> $categorie2->translate($_locale)->getTitreCategorie(),'active'=> true];
  650.             $breadcrumb_item $breadcrumb_item 1;
  651.             $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(["@id"=> $this->generateUrl('page_sous_categorie'
  652.             ['categorie1'=> $categorie1->translate($_locale)->getSlugUrl(),'categorie2'=> $categorie2->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  653.             "name"=> $categorie2->translate($_locale)->getTitreCategorie()]);
  654.             // categorie 3
  655.             $breadcrumb [] = ['url'=> $this->generateUrl('page_sous_sous_categorie', [
  656.             'categorie1'=> $categorie1->translate($_locale)->getSlugUrl(),'categorie2'=> $categorie2->translate($_locale)->getSlugUrl(),
  657.             'categorie3'=> $categorie3->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  658.             'name'=> $categorie3->translate($_locale)->getTitreCategorie(),'active'=> true];
  659.             $breadcrumb_item $breadcrumb_item 1;
  660.             $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(["@id"=> $this->generateUrl('page_sous_sous_categorie'
  661.             ['categorie1'=> $categorie1->translate($_locale)->getSlugUrl(),'categorie2'=> $categorie2->translate($_locale)->getSlugUrl(),
  662.              'categorie3'=> $categorie2->translate($_locale)->getSlugUrl()], UrlGeneratorInterface::ABSOLUTE_URL),
  663.              "name"=> $categorie3->translate($_locale)->getTitreCategorie()]);
  664.             $breadcrumb_item $breadcrumb_item 1;
  665.             $url $this->generateUrl('page_produit', ['categorie1'=> $categorie1->translate($_locale)->getSlugUrl(),
  666.                         'categorie2'=> $categorie2->translate($_locale)->getSlugUrl(),
  667.                         'categorie3'=> $categorie3->translate($_locale)->getSlugUrl(),
  668.                         'slug_produit'=> $post->translate($_locale)->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  669.             $schema_breadcrumb_items[] = Schema::ListItem()->position($breadcrumb_item)->item(["@id"=> $url,"name"=> $title_post_ariane]);
  670.             $breadcrumb [] = ['url'=> $url,"name"=> $title_post_ariane,'active'=> false];
  671.         }
  672.         $schemaOrg->add(Schema::Article()->headline($title_post_ariane)
  673.                                          ->datePublished($post->getDatePublication()?$post->getDatePublication():$post->getCreatedAt())
  674.                                          ->dateModified($post->getUpdatedAt())
  675.                                          ->image($post->getImage()!= null?$baseurl.$post->getImage():'')
  676.                                          ->publisher(Schema::Organization()
  677.                                          ->name($this->functionService->parametreGenerale()?$this->functionService->parametreGenerale()->translate($_locale)->getTitre():'')
  678.                                          ->logo($this->functionService->parametreGenerale()?$baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getImage():''))
  679.                                          ->mainEntityOfPage(Schema::WebPage()->url($url))
  680.                                         );
  681.         $url_social = [];
  682.         $social $this->getDoctrine()->getRepository(ReseauSociaux::class)->findAll();
  683.         if($social){
  684.             foreach ($social as $value) {
  685.                 $url_social[] = $value->getUrl();
  686.             }
  687.         }
  688.         // id categorie related with post 
  689.         $categoiesPosts $this->getDoctrine()->getRepository(PostCategory::class)->findCategorieByPost($post->getId());
  690.         $next_article $this->getDoctrine()->getRepository(Post::class)->findPostPrevOrNext($categoiesPosts,$post->getId());
  691.         $prev_article $this->getDoctrine()->getRepository(Post::class)->findPostPrevOrNext($categoiesPosts,$post->getId(),'prev');
  692.         $template_model_galerie $modele_gallerie[0]->getTwig();
  693.         $categories_tree = [];
  694.         $categories_principal =  $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> 0,'TypePost'=> $post->getTypePost()],['position'=> 'ASC']);
  695.         if ($categories_principal) {
  696.             foreach ($categories_principal as $value) {
  697.                 $data_slug_sous_categorie = [];
  698.                 $tree_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> $value->getId()],['position'=>'ASC']);
  699.                 if($tree_sous_categorie){
  700.                     foreach ($tree_sous_categorie as $sous_categorie_items) {
  701.                         $data_slug_sous_sous_categorie = [];
  702.                         $tree_sous_sous_categorie $this->getDoctrine()->getRepository(Category::class)->findBy(['actif'=> true,'parent'=> 0,'sousParent'=> $sous_categorie_items->getId()],['position'=>'ASC']);
  703.                         if ($tree_sous_sous_categorie) {
  704.                             foreach ($tree_sous_sous_categorie as  $sous_sous_categorie_items) {
  705.                                 $data_slug_sous_sous_categorie[] = [
  706.                                 'id'=> $sous_sous_categorie_items->getId(),
  707.                                 'titre'=> $sous_sous_categorie_items->translate($_locale)->getTitreCategorie(),
  708.                                 'slug'=> $sous_sous_categorie_items->translate($_locale)->getSlugUrl()];
  709.                             }
  710.                         }
  711.                         $data_slug_sous_categorie[] = ['id'=> $sous_categorie_items->getId(),
  712.                                                        'titre'=> $sous_categorie_items->translate($_locale)->getTitreCategorie(),
  713.                                                        'slug'=> $sous_categorie_items->translate($_locale)->getSlugUrl(),
  714.                                                        'sous_sous_categories'=> $data_slug_sous_sous_categorie,
  715.                                                       ];
  716.                     }
  717.                 }
  718.                 $categories_tree[] = ['id'=> $value->getId(),
  719.                                       'titre'=> $value->translate($_locale)->getTitreCategorie(),
  720.                                       'slug'=> $value->translate($_locale)->getSlugUrl(),
  721.                                       'sous_categories'=> $data_slug_sous_categorie,
  722.                                     ];
  723.             }
  724.         }
  725.         $parametre $this->functionService->parametreGenerale();
  726.         $produit_related null;
  727.         $resultats_first_images_produits = [];
  728.         // Find product related with default categorie
  729.         // if($post->getDefaultCategorie()){
  730.         //     $canonical = $this->functionService->canonicalUrlProduit($post);
  731.         //     $produit_related = $this->getDoctrine()->getRepository(Post::class)->findProductRelated($post->getTypePost(),$post->getId(),$post->getDefaultCategorie());
  732.         //     if($produit_related){
  733.         //         foreach ($produit_related as $value) {
  734.         //             $galleries_first_image = $this->affichageGallerieService->FirstGallerieImagePost($value);
  735.         //             $resultats_first_images_produits[] = [ 
  736.         //                 'id'=> $value->getId(),
  737.         //                 'galleries_first_image'=> $galleries_first_image
  738.         //             ];
  739.         //         }
  740.         //     }
  741.         // }else{
  742.         //     $canonical = $this->functionService->canonicalUrl($post->translate($_locale)->getCanonical());
  743.         // }
  744.         // Find product related 
  745.         if ($post->getPostsAssocies()) {
  746.             $canonical $this->functionService->canonicalUrlProduit($post);
  747.             foreach (explode(',',$post->getPostsAssocies()) as $id) {
  748.                 $produit =  $this->getDoctrine()->getRepository(Post::class)->find($id);
  749.                 if ($produit) {
  750.                     $produit_related[] = $produit;
  751.                     $galleries_first_image $this->affichageGallerieService->FirstGallerieImagePost($produit);
  752.                     $resultats_first_images_produits[] = [ 
  753.                         'id'=> $produit->getId(),
  754.                         'galleries_first_image'=> $galleries_first_image
  755.                     ];
  756.                 }
  757.             }
  758.         }else{
  759.             $canonical $this->functionService->canonicalUrl($post->translate($_locale)->getCanonical());
  760.         }
  761.      
  762.         $champsPersonnalisesPost = [];
  763.         $champsPersonnalisesPost $this->functionService->getChampsPersonnalisesPost($post);
  764.         return $template =  $this->render('front/'.$this->theme.'/produits/page_produit.html.twig',[
  765.             'post'=> $post,
  766.             'produit_related'=> $produit_related,
  767.             'canonical'=> $canonical,
  768.             'parametre'=> $parametre,
  769.             'title_home_ariane' => $title_home_ariane,
  770.             'galleries'=> $galleries_images,
  771.             'categories_tree'=> $categories_tree,
  772.             'categorie'=> $categorie1,
  773.             'sous_categorie'=> $categorie2,
  774.             'sous_sous_categorie'=> $categorie3,
  775.             'show_filter_categorie'=> $show_filter_categorie,
  776.             'docs'=> $docs,
  777.             'blocs'=> $bloc_post,
  778.             'meta_robots'=> $meta_robots,
  779.             'schemaOrg'=> $schemaOrg,
  780.             'custom_schemaOrg'=> $custom_schemaOrg,
  781.             'next_article'=> $next_article,
  782.             'prev_article'=> $prev_article,
  783.             'modele_galerie' => $modele_gallerie,
  784.             'template_model_gallerie' => $template_model_galerie,
  785.             'breadcrumb'=> $breadcrumb,
  786.             'resultats_first_images_produits'=> $resultats_first_images_produits,
  787.             'champsPersonnalisesPost' => $champsPersonnalisesPost,
  788.             'param_post' => $parametrePost
  789.         ]);
  790.     }
  791.     function MetaModulePostOrCategory($request,$slug,$type){
  792.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  793.         $metaService $this->metaService->meta($slug,$type);
  794.         $title_seo =  isset($metaService['title'])?$metaService['title']:null;
  795.         $description_seo = isset($metaService['description'])?$metaService['description']:null;
  796.         $metacle = isset($metaService['metacle'])?$metaService['metacle']:null;
  797.         if($title_seo != '' || $description_seo != ''){
  798.             $this->basicSeo->setTitle(strip_tags($title_seo))
  799.                         ->setDescription($description_seo)
  800.                         ->setkeywords($metacle);
  801.             $this->seo->setTitle(strip_tags($title_seo))
  802.                     ->setDescription($description_seo);
  803.                     //->setUrl($url);
  804.             if ($this->functionService->parametreGenerale()) {
  805.                 if ($this->functionService->parametreGenerale()->getApercuImageLien()) {
  806.                     $this->seo->setImage($baseurl.'/public/uploads/images/'.$this->functionService->parametreGenerale()->getApercuImageLien());
  807.                 }
  808.             }
  809.         }
  810.     }
  811. }