src/Controller/ApplicationController.php line 76

  1. <?php
  2. namespace App\Controller;
  3. use App\Services\DbMenu;
  4. use App\Services\DbPage;
  5. use App\Services\DbProduct;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. class ApplicationController extends AbstractController
  11. {
  12.     #[Route(
  13.         path: ['fr' => '/{_locale}/applications''en' => '/{_locale}/applications'], 
  14.         name'applications_menu'
  15.         requirements: [
  16.             '_locale' => 'en|fr',
  17.         ], 
  18.         priority4
  19.     )]
  20.     public function applications_menu(Request $requestDbMenu $dbMenu): Response
  21.     {
  22.         if ($request->getLocale() == 'fr') {
  23.             $link '/en/applications';
  24.             $breadcrumb = array(['name' => 'Applications''link_rewrite' => 'applications']);
  25.             $lienDb "applications";
  26.         } else {
  27.             $link '/fr/applications';
  28.             $breadcrumb = array(['name' => 'Applications''link_rewrite' => 'applications']);
  29.             $lienDb "applications";
  30.         }
  31.         $parent $dbMenu->getContent($lienDb$request->getLocale());
  32.         $menus $dbMenu->getMenus($parent[0]['id_cms_category'], $request->getLocale());
  33.         $menusCms $dbMenu->getMenusCms($parent[0]['id_cms_category'], $request->getLocale());
  34.         
  35.         return $this->render('apropos/aproposmenu.html.twig', ['link' => $link'breadcrumb' => $breadcrumb'menus' => $menus'menusCms' => $menusCms]);
  36.     }
  37.     #[Route(
  38.         path: ['fr' => '/{_locale}/applications/{link}''en' => '/{_locale}/applications/{link}'], 
  39.         name'applications_sousmenu'
  40.         requirements: [
  41.             '_locale' => 'en|fr',
  42.         ], 
  43.         priority3
  44.     )]
  45.     public function applications_sousmenu(Request $requestDbMenu $dbMenu$link null): Response
  46.     {
  47.         if ($request->getLocale() == 'fr') {
  48.             $altlink '/en/applications';
  49.             $breadcrumb = array(['name' => 'Applications''link_rewrite' => 'applications']);
  50.         } else {
  51.             $altlink '/fr/applications';
  52.             $breadcrumb = array(['name' => 'Applications''link_rewrite' => 'applications']);
  53.         }
  54.         
  55.         $parent $dbMenu->getContent($link$request->getLocale());
  56.         $content = array(['meta_title' => $parent[0]['name'], 'link_rewrite' => $link]);
  57.         $menus $dbMenu->getMenus($parent[0]['id_cms_category'], $request->getLocale());
  58.         $menusCms $dbMenu->getMenusCms($parent[0]['id_cms_category'], $request->getLocale());
  59.         
  60.         return $this->render('apropos/aproposmenu.html.twig', ['link' => $link'breadcrumb' => $breadcrumb'menus' => $menus'menusCms' => $menusCms'contents' => $content]);
  61.     }
  62.     #[Route(
  63.         path: ['fr' => '/{_locale}/applications/{categorie}/{link}''en' => '/{_locale}/applications/{categorie}/{link}'], 
  64.         name'application'
  65.         requirements: [
  66.             '_locale' => 'en|fr',
  67.         ], 
  68.         priority2
  69.     )]
  70.     public function application(Request $requestDbPage $dbPageDbProduct $dbProduct$categorie null$link null): Response
  71.     {
  72.         $breadcrumb = [];
  73.         foreach (explode('/'$request->getPathInfo()) as $path) {
  74.             if (($cat $dbProduct->getCategories($request->getLocale(), $path)) != []) {
  75.                 $breadcrumb[] = [
  76.                     'name' => $cat[0]["name"],
  77.                     'link_rewrite' => $cat[0]["link_rewrite"]
  78.                 ];
  79.             }
  80.         }
  81.         $contents $dbPage->getContent($link$request->getLocale());
  82.         $link $dbPage->getLink($contents[0]['id_cms'], $request$categorie);
  83.         $appProduct = [];
  84.         $references "";
  85.         if (preg_match_all('/\{products\}(.*?)\{\/products\}/'$contents[0]['content'], $matches)) {
  86.             $resultats $matches[1];
  87.             foreach ($resultats as $resultat) {
  88.                 $references .= $references == "" $resultat ','.$resultat;
  89.             }
  90.             foreach (explode(","$references) as $reference) {
  91.                 if ($product $dbProduct->getProductReferenceApplication($request->getLocale(), $reference)) {
  92.                     array_push($appProduct$product[0]);
  93.                 }
  94.             }
  95.         }
  96.         $i 0;
  97.         $remplacement "";
  98.         $menus $dbProduct->getProductApplicationMenu($request->getLocale());
  99.         return $this->render('application/application.html.twig', ['contents' => $contents'link' => $link'products' => $appProduct'menus' => $menus'breadcrumb' => $breadcrumb]);
  100.     }
  101. }
  102. ?>