src/Controller/Front/ActualitesController.php line 44

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\Contact;
  6. use App\Entity\Country;
  7. use App\Entity\Language;
  8. use App\Entity\ListeRef;
  9. use App\Entity\Secteurs;
  10. use App\Entity\Activites;
  11. use App\Entity\GroupBloc;
  12. use App\Entity\ListeMenu;
  13. use App\Service\BuildTree;
  14. use Spatie\SchemaOrg\Graph;
  15. use App\Entity\ParamContact;
  16. use App\Entity\ParametreRef;
  17. use App\Entity\ThemeOptions;
  18. use Spatie\SchemaOrg\Schema;
  19. use App\Entity\ParametreSite;
  20. use App\Entity\ProduitOption;
  21. use App\Entity\ReseauSociaux;
  22. use App\Entity\TextParametrable;
  23. use App\Entity\CategoriesProduct;
  24. use App\Entity\ActiviteSecondaire;
  25. use App\Service\RenderDefaultBloc;
  26. use App\Entity\TextParametrableTranslation;
  27. use Symfony\Component\Filesystem\Filesystem;
  28. use Symfony\Component\HttpFoundation\Request;
  29. use Symfony\Component\HttpFoundation\Response;
  30. use Symfony\Component\Routing\Annotation\Route;
  31. use Symfony\Contracts\HttpClient\HttpClientInterface;
  32. use Symfony\Component\Translation\TranslatorInterface;
  33. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  34. use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
  35. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  36. class ActualitesController  extends AbstractController
  37. {
  38.     public function __construct(string $theme,HttpClientInterface $client,string $projectDirr)
  39.     {
  40.         $this->theme $theme;
  41.         $this->client $client;
  42.         $this->projectDirr $projectDirr;
  43.     }
  44.     /**
  45.      * @Route("/nos-actualites", name="page_nos_actualites", options={"sitemap" = true},priority=10)
  46.      */
  47.     public function index(Request $request)
  48.     {
  49.         $_locale $request->getLocale();
  50.         $resultat= [];
  51.         $pages $this->getDoctrine()->getRepository(Post::class)->findActualiteByActivite();
  52.         if ($pages) {
  53.             foreach ($pages as $value) {
  54.                 $resultat [] = ['titre'=> $value->translate($_locale)->getTitle(),
  55.                                 'slug'=> $value->translate($_locale)->getSlug(),
  56.                                ];
  57.             }
  58.         }
  59.         $home $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
  60.         $title_home_ariane $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
  61.         $schemaOrg = new Graph();
  62.         $breadcrumb = [];
  63.         $schema_breadcrumb_items = [];
  64.         
  65.         $breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane,'active'=> true];
  66.         $schema_breadcrumb_items[] = Schema::ListItem()
  67.                                      ->position(1)
  68.                                      ->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
  69.         
  70.         $breadcrumb [] = ['url'=> $this->generateUrl('page_nos_actualites', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> 'Nos Actualités','active'=> true];
  71.         $schema_breadcrumb_items[] = Schema::ListItem()
  72.                                     ->position(2)
  73.                                     ->item(["@id"=> $this->generateUrl('page_nos_actualites', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> 'Nos Actualités']);
  74.                       
  75.         $schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
  76.         return $this->render('front/'.$this->theme.'/hub_actualites.html.twig',[
  77.             'actualites'=> $resultat,
  78.             'breadcrumb'=> $breadcrumb,
  79.             'schemaOrg'=> $schemaOrg,
  80.         ]);
  81.     }
  82.     
  83. }