<?php
namespace App\Controller\Front;
use App\Entity\Menu;
use App\Entity\Post;
use App\Entity\Contact;
use App\Entity\Country;
use App\Entity\Language;
use App\Entity\ListeRef;
use App\Entity\Secteurs;
use App\Entity\Activites;
use App\Entity\GroupBloc;
use App\Entity\ListeMenu;
use App\Service\BuildTree;
use Spatie\SchemaOrg\Graph;
use App\Entity\ParamContact;
use App\Entity\ParametreRef;
use App\Entity\ThemeOptions;
use Spatie\SchemaOrg\Schema;
use App\Entity\ParametreSite;
use App\Entity\ProduitOption;
use App\Entity\ReseauSociaux;
use App\Entity\TextParametrable;
use App\Entity\CategoriesProduct;
use App\Entity\ActiviteSecondaire;
use App\Service\RenderDefaultBloc;
use App\Entity\TextParametrableTranslation;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class ActualitesController extends AbstractController
{
public function __construct(string $theme,HttpClientInterface $client,string $projectDirr)
{
$this->theme = $theme;
$this->client = $client;
$this->projectDirr = $projectDirr;
}
/**
* @Route("/nos-actualites", name="page_nos_actualites", options={"sitemap" = true},priority=10)
*/
public function index(Request $request)
{
$_locale = $request->getLocale();
$resultat= [];
$pages = $this->getDoctrine()->getRepository(Post::class)->findActualiteByActivite();
if ($pages) {
foreach ($pages as $value) {
$resultat [] = ['titre'=> $value->translate($_locale)->getTitle(),
'slug'=> $value->translate($_locale)->getSlug(),
];
}
}
$home = $this->getDoctrine()->getRepository(Post::class)->findPostBySlug('Home');
$title_home_ariane = $home->getBreadcrumb() ? $home->getBreadcrumb() : "Accueil";
$schemaOrg = new Graph();
$breadcrumb = [];
$schema_breadcrumb_items = [];
$breadcrumb [] = ['url'=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane,'active'=> true];
$schema_breadcrumb_items[] = Schema::ListItem()
->position(1)
->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> $title_home_ariane]);
$breadcrumb [] = ['url'=> $this->generateUrl('page_nos_actualites', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> 'Nos Actualités','active'=> true];
$schema_breadcrumb_items[] = Schema::ListItem()
->position(2)
->item(["@id"=> $this->generateUrl('page_nos_actualites', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=> 'Nos Actualités']);
$schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
return $this->render('front/'.$this->theme.'/hub_actualites.html.twig',[
'actualites'=> $resultat,
'breadcrumb'=> $breadcrumb,
'schemaOrg'=> $schemaOrg,
]);
}
}