src/Controller/Front/PartenairesController.php line 196

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\Entity\ParametrePartenaires;
  23. use App\Entity\ParametrePartenairesTranslation;
  24. use App\Entity\Partenaires;
  25. use App\Entity\PartenairesTranslation;
  26. use App\Service\MetaService;
  27. use Spatie\SchemaOrg\Schema;
  28. use App\Entity\ModelGallerie;
  29. use App\Entity\ParametreSite;
  30. use App\Entity\ReseauSociaux;
  31. use App\Service\MetaClePageRef;
  32. use App\Service\FunctionService;
  33. use App\Entity\ActiviteSecondaire;
  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\HttpClient\HttpClient;
  45. use Symfony\Component\HttpFoundation\RequestStack;
  46. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  47. class PartenairesController 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 $requestStack;
  61.     
  62.     public function __construct(string $projectDir,string $theme,
  63.                                 BasicSeoGenerator $basicSeo,
  64.                                 OgSeoGenerator $seo,
  65.                                 RenderBloc $renderBloc,
  66.                                 SluggerInterface $slugger,
  67.                                 BuildTree $buildTree,
  68.                                 MetaService $metaService,
  69.                                 MetaWithoutCategoryService $metaPostService,
  70.                                 MetaClePageRef $metaClePageRef,
  71.                                 FunctionService $functionService,
  72.                                 RequestStack $requestStack){
  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->renderBloc $renderBloc;
  82.         $this->projectDir $projectDir;
  83.         $this->theme $theme;
  84.         $this->requestStack $requestStack;
  85.     } 
  86.     /**
  87.      * @Route("/partenaires", name="page_partenaire",priority=10)
  88.      */
  89.     public function PagePartenaires(Request $request)
  90.     {
  91.         $parametreSite $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy([],['id'=> 'ASC']);
  92.         $param_partenaire $this->getDoctrine()->getRepository(ParametrePartenaires::class)->findOneBy(['actif'=> true]);
  93.         $liste_partenaire_bo $this->getDoctrine()->getRepository(Partenaires::class)->findBy(['actif'=> true]);
  94.         $client HttpClient::create();
  95.         $request $this->requestStack->getCurrentRequest();
  96.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  97.         $partenaires_invitations null;
  98.         try {
  99.             $response_api $client->request('GET',
  100.                 $parametreSite->getDomainApiHrz().'/api/custom/all-partners-domain',
  101.                 [ 'headers' => ['Accept' => 'application/json'],
  102.                 'query' => [
  103.                     'domain' => $baseurl,
  104.                     'token' => $parametreSite->getTokenApiHrz(),
  105.                     ],
  106.                 ]);
  107.             if ($response_api->getStatusCode() === 200) {
  108.                 $partenaires_invitations $response_api->toArray()['data'];
  109.             }
  110.         } catch (\Throwable $th) {
  111.             //throw $th;
  112.             //dump($th);
  113.         }
  114.         /* if(!$partenaires_invitations){
  115.             throw new NotFoundHttpException('Sorry not existing!');
  116.         } */
  117.         return $this->render('front/'.$this->theme.'/page_partenaires.html.twig',[
  118.             'parametre'=> $param_partenaire,
  119.             'liste_partenaire' => $liste_partenaire_bo,
  120.             'liste_partenaire_invitations' => $partenaires_invitations,
  121.             'baseurl' => $baseurl
  122.         ]);
  123.     }
  124.     
  125.     /**
  126.      * @Route("/partenaire/{slug}", name="page_detail_partenaire",priority=10)
  127.      */
  128.     public function DetailsPartenaires(Request $request,$slug null)
  129.     {
  130.         $api $request->query->get('p');
  131.         if($api == "hr"){
  132.             // Api
  133.             $parametreSite $this->getDoctrine()->getRepository(ParametreSite::class)->findOneBy([],['id'=> 'ASC']);
  134.             $client HttpClient::create();
  135.             $request $this->requestStack->getCurrentRequest();
  136.             $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  137.             $partenaire_api null;
  138.             $partenaire = [];
  139.             try {
  140.                 $response_api $client->request('GET',
  141.                     $parametreSite->getDomainApiHrz().'/api/custom/partner-detail',
  142.                     [ 'headers' => ['Accept' => 'application/json'],
  143.                     'query' => [
  144.                         'domain' => $baseurl,
  145.                         'slug' => $slug,
  146.                         'token' => $parametreSite->getTokenApiHrz(),
  147.                         ],
  148.                     ]);
  149.                 if ($response_api->getStatusCode() === 200) {
  150.                     $partenaire_api $response_api->toArray()['data'];
  151.                 }
  152.             } catch (\Throwable $th) {
  153.                 //throw $th;
  154.                 //dump($th);
  155.             }
  156.             $titre "";
  157.             $texte "";
  158.             $image "";
  159.             $titre = ($partenaire_api['domaine_sender'] == $baseurl) ? $partenaire_api['titre_reciver'] : $titre;
  160.             $titre = ($partenaire_api['domaine_reciver'] == $baseurl) ? $partenaire_api['titre_sender'] : $titre;
  161.             $texte = ($partenaire_api['domaine_sender'] == $baseurl) ? $partenaire_api['texte_reciver'] : $texte;
  162.             $texte = ($partenaire_api['domaine_reciver'] == $baseurl) ? $partenaire_api['texte_sender'] : $texte;
  163.             $image = ($partenaire_api['domaine_sender'] == $baseurl) ? $partenaire_api['image_reciver'] : $image;
  164.             $image = ($partenaire_api['domaine_reciver'] == $baseurl) ? $partenaire_api['image_sender'] : $image;
  165.             $partenaire = [
  166.                 'titre' => $titre,
  167.                 'text' => $texte,
  168.                 'image' => $image
  169.             ];
  170.         }else{
  171.             $partenaire $this->getDoctrine()->getRepository(Partenaires::class)->findBySlug($slug);
  172.         }
  173.        
  174.         if(!$partenaire){
  175.             throw new NotFoundHttpException('Sorry not existing!');
  176.         }
  177.         return $this->render('front/'.$this->theme.'/page_detail_partenaires.html.twig',[
  178.             'partenaire'=> $partenaire,
  179.         ]);
  180.     }
  181. }
  182. ?>