src/Controller/Front/HomeController.php line 71

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Entity\System\Language;
  4. use App\Service\EnvironmentService;
  5. use App\ViewManager\Landing\HomeService;
  6. use App\ViewManager\Landing\LandingService;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\RequestStack;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. class HomeController extends AbstractController
  14. {
  15.     private HomeService $homeService;
  16.     public RequestStack $requestStack;
  17.     private LandingService $landingService;
  18.     private EnvironmentService $environmentService;
  19.     public function __construct(
  20.         HomeService $homeService,
  21.         RequestStack $requestStack,
  22.         LandingService $landingService,
  23.         EnvironmentService $environmentService
  24.     ) {
  25.         $this->homeService $homeService;
  26.         $this->requestStack $requestStack;
  27.         $this->landingService $landingService;
  28.         $this->environmentService $environmentService;
  29.     }
  30.     /**
  31.      * @Route("/", name="homepage_default", priority=-5, methods={"GET"})
  32.      * @Route({
  33.      * "default": "/",
  34.      * "en": "/en/",
  35.      * "es": "/es/",
  36.      * "fr": "/fr/",
  37.      * "de": "/de/",
  38.      * "pt": "/pt/",
  39.      * "el": "/el/",
  40.      * "hr": "/hr/",
  41.      * "it": "/it/",
  42.      * "et": "/et/",
  43.      * "da": "/da/",
  44.      * "fi": "/fi/",
  45.      * "ro": "/ro/",
  46.      * "bg": "/bg/",
  47.      * "hu": "/hu/",
  48.      * "sk": "/sk/",
  49.      * "si": "/si/",
  50.      * "lt": "/lt/",
  51.      * "lv": "/lv/",
  52.      * "pl": "/pl/",
  53.      * "nl": "/nl/",
  54.      * "ru": "/ru/",
  55.      * "no": "/no/",
  56.      * "sv": "/sv/",
  57.      * "cs": "/cs/"*
  58.      *  }, name="homepage", priority=-5, methods={"GET"})
  59.      */
  60.     public function corporative(Request $request): Response
  61.     {
  62.         if ($this->environmentService->isApi()) {
  63.             return new JsonResponse(['code' => 'Bad request''message' => Response::HTTP_BAD_REQUEST, ], Response::HTTP_BAD_REQUEST);
  64.         }
  65.         $this->requestStack->getSession()->set('isHome'true);
  66.         $isoCode $request->getSession()->get('lang') ?? 'es';
  67.         $metaData $this->homeService->getMetaData($isoCode);
  68.         $langFabImage in_array($isoCode, [Language::SPANISH_ISOLanguage::ENGLISH_ISO]) ? $isoCode Language::ENGLISH_ISO;
  69.         return $this->render(
  70.             'front/home/index.html.twig',
  71.             [
  72.                 'landingHtml' => $this->landingService->getLandingContentInternal('corporative-home'),
  73.                 'metas' => $metaData,
  74.                 'iso_code_lang' => $isoCode,
  75.                 'iso_code_lang_fab' => $langFabImage,
  76.                 'show_tab_tag' => true,
  77.             ]
  78.         );
  79.     }
  80.     /**
  81.      * @Route("dinamicDataHome", methods={"GET"})
  82.      */
  83.     public function dinamicDataHome(): Response
  84.     {
  85.         $language $this->requestStack->getSession()->get('lang');
  86.         $dinamicDataHome $this->homeService->dinamicDataHome(
  87.             $language
  88.         );
  89.         return new Response(
  90.             $dinamicDataHome,
  91.             Response::HTTP_OK,
  92.             ['content-type' => 'application/json']
  93.         );
  94.     }
  95. }