<?php
namespace App\Controller\Front;
use App\Entity\Menu;
use App\Entity\Post;
use App\Entity\UrlRef;
use App\Entity\UrlPost;
use App\Entity\Category;
use App\Entity\Language;
use App\Entity\MediaCms;
use App\Entity\Secteurs;
use App\Entity\TypePost;
use App\Entity\ListeMenu;
use App\Service\BuildTree;
use App\Entity\CpPostField;
use App\Entity\PostArchive;
use App\Service\RenderBloc;
use Spatie\SchemaOrg\Graph;
use App\Entity\ParametreRef;
use App\Service\MetaService;
use Spatie\SchemaOrg\Schema;
use App\Entity\ParametreSite;
use App\Entity\ReseauSociaux;
use App\Service\MetaClePageRef;
use App\Service\FunctionService;
use App\Service\MetaWithoutCategoryService;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Leogout\Bundle\SeoBundle\Seo\Og\OgSeoGenerator;
use Symfony\Component\String\Slugger\SluggerInterface;
use Leogout\Bundle\SeoBundle\Seo\Basic\BasicSeoGenerator;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class PageStatiqueController extends AbstractController
{
public $basicSeo;
public $seo;
private $slugger;
private $projectDir;
private $metaService;
private $metaClePageRef;
private $renderBloc;
private $buildTree;
private $functionService;
private $metaPostService;
private $theme;
public function __construct(string $projectDir,string $theme,
BasicSeoGenerator $basicSeo,
OgSeoGenerator $seo,
RenderBloc $renderBloc,
SluggerInterface $slugger,
BuildTree $buildTree,
MetaService $metaService,
MetaWithoutCategoryService $metaPostService,
MetaClePageRef $metaClePageRef,
FunctionService $functionService){
$this->metaService = $metaService;
$this->metaPostService = $metaPostService;
$this->basicSeo = $basicSeo;
$this->seo = $seo;
$this->buildTree = $buildTree;
$this->slugger = $slugger;
$this->metaClePageRef = $metaClePageRef;
$this->functionService = $functionService;
$this->renderBloc = $renderBloc;
$this->projectDir = $projectDir;
$this->theme = $theme;
}
/**
* @Route("/plan-du-site", priority=10 , name="plan_du_site", options={"sitemap" = true})
*/
public function PlanDuSite(Request $request)
{
$schemaOrg = new Graph();
$menu_principal = [];
$post = ["title"=> "Plan du site"];
$meta_robots = "INDEX,FOLLOW";
$Menu_right = $this->getDoctrine()->getRepository(ListeMenu::class)->findOneBy(['type'=>'Header-right','IdSite'=> '1']);
if($Menu_right){
$ListMenu_rigth = $this->getDoctrine()->getRepository(Menu::class)->findMenuActif($Menu_right->getId());
$menu_principal = $this->buildTree->buildMenu($ListMenu_rigth);
}
$schema_breadcrumb_items = [];
$schema_breadcrumb_items[] = Schema::ListItem()
->position(1)
->item(["@id"=> $this->generateUrl('index_home', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=>"Accueil"]);
$schema_breadcrumb_items[] = Schema::ListItem()
->position(2)
->item(["@id"=> $this->generateUrl('plan_du_site', [], UrlGeneratorInterface::ABSOLUTE_URL),"name"=>'Plan du site']);
if ($schema_breadcrumb_items) {
$schemaOrg->add(Schema::BreadcrumBList()->itemListElement($schema_breadcrumb_items));
}
return $this->render('front/'.$this->theme.'/page_plan_site.html.twig',[
'meta_robots'=> $meta_robots,
'post'=> $post,
'menu_principal'=> $menu_principal,
'schemaOrg'=> $schemaOrg
]);
}
// /**
// * @Route("/{slug}", name="secteur_activite")
// */
// public function PageController(Request $request,$slug)
// {
// $url_ref = $this->getDoctrine()->getRepository(UrlRef::class)->findRefBySlug($slug);
// $this->metaClePageRef->meta($url_ref);
// if($url_ref->getType() === "Secteur"){
// $secteur = $this->getDoctrine()->getRepository(Secteurs::class)->find($url_ref->getIdModule());
// $activites = $this->getDoctrine()->getRepository(UrlRef::class)->findBy(['type'=>'Activite','id_secteur'=>$secteur->getId()]);
// $resultat = ['slug'=> $secteur->getLibelleUrl(),
// 'titre_secteur'=> $url_ref->getTitreSecteur(),
// 'texte_secteur'=> $url_ref->getTexteSecteur(),
// 'activites'=> $activites,
// ];
// $template = $this->render('front/secteur.html.twig',[
// 'resultat'=> $resultat,
// ]);
// }elseif($url_ref->getType() === "Activite"){
// $parametreRef = $this->getDoctrine()->getRepository(ParametreRef::class)->find(1);
// $RandomSecteurs = null;
// $RandomActivites = null;
// $secteur = $url_ref->getIdSecteur();
// $activite = $url_ref->getIdActivite();
// if($parametreRef->getNbMaillageSecteur() != ''){
// $NbMaillageSecteur = $parametreRef->getNbMaillageSecteur();
// $RandomSecteurs = $this->getDoctrine()->getRepository(Secteurs::class)->findRandomSecteur($NbMaillageSecteur,$secteur->getId());
// }
// if($parametreRef->getNbMaillageActivite() != ''){
// $NbMaillageActivite = $parametreRef->getNbMaillageActivite();
// $RandomActivites = $this->getDoctrine()->getRepository(UrlRef::class)->findRandomActiviteBySecteur($NbMaillageActivite,$secteur->getId(),$activite->getId());
// }
// $resultat = ['titre_secteur'=> $secteur->getTitreSecteur(),
// 'slug_secteur'=> $secteur->getLibelleUrl(),
// 'titre_activite'=> $url_ref->getTitreActivite(),
// 'texte_activite'=> $url_ref->getTexteActivite(),
// 'maillage_secteur'=> $RandomSecteurs,
// 'maillage_activite'=> $RandomActivites,
// ];
// $template = $this->render('front/activite.html.twig',[
// 'resultat'=> $resultat,
// 'parametreRef'=> $parametreRef,
// ]);
// }
// return $template;
// }
/**
* @Route("/page-archive/{id}", name="page_cms_archive")
*/
public function PageCmsArchive(Request $request,$id)
{
$_locale = $request->getLocale();
$post = $this->getDoctrine()->getRepository(PostArchive::class)->find($id);
if(!$post){
throw new NotFoundHttpException('Sorry not existing!');
}
return $this->render('front/'.$this->theme.'/page_cms.html.twig',[
'post'=> $post,
]);
}
}