src/Controller/Front/LegalController.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use App\Manager\InfoManager;
  9. use App\Manager\LegalCookiePolicyManager;
  10. use App\Manager\LegalFinancingManager;
  11. use App\Manager\LegalInformationManager;
  12. use App\Manager\LegalPrivacyPolicyManager;
  13. use App\Manager\LegalTermConditionManager;
  14. use App\Manager\LegalUseConditionManager;
  15. use App\Manager\ConductaProveedorManager;
  16. class LegalController extends AbstractController
  17. {
  18.     protected array $locals = [];
  19.     public function __construct(private InfoManager $info_mgr)
  20.     {
  21.         $this->locals['menu_active'] = '';
  22.     }
  23.     #[Route(path'/condiciones-de-uso/'name'terms_of_use'methods: ['GET'])]
  24.     #[Template('front/legal/terms_use.html.twig')]
  25.     public function termsUseAction(Request $requestLegalUseConditionManager $lucmgr): array
  26.     {
  27.         $this->locals['home'] = $lucmgr->find(1);
  28.         return $this->locals;
  29.     }
  30.     #[Route(path'/terminos-y-condiciones/'name'terms_conditions'methods: ['GET'])]
  31.     #[Template('front/legal/terms_conditions.html.twig')]
  32.     public function termsConditionsAction(Request $requestLegalTermConditionManager $ltcmgr): array
  33.     {
  34.         $this->locals['home'] = $ltcmgr->find(1);
  35.         return $this->locals;
  36.     }
  37.     #[Route(path'/politicas-de-cookies/'name'cookie_policies'methods: ['GET'])]
  38.     #[Template('front/legal/cookie_policies.html.twig')]
  39.     public function cookiePoliciesAction(Request $requestLegalCookiePolicyManager $lcpmgr): array
  40.     {
  41.         $this->locals['home'] = $lcpmgr->find(1);
  42.         return $this->locals;
  43.     }
  44.     #[Route(path'/informacion-legal/'name'legal_information'methods: ['GET'])]
  45.     #[Template('front/legal/legal_information.html.twig')]
  46.     public function legalInformationAction(Request $requestLegalInformationManager $limgr): array
  47.     {
  48.         $this->locals['home'] = $limgr->find(1);
  49.         return $this->locals;
  50.     }
  51.     #[Route(path'/politicas-de-privacidad/'name'privacy_policies'methods: ['GET'])]
  52.     #[Template('front/legal/privacy_policies.html.twig')]
  53.     public function privacyPoliciesAction(Request $requestLegalPrivacyPolicyManager $lppmgr): array
  54.     {
  55.         $this->locals['home'] = $lppmgr->find(1);
  56.         return $this->locals;
  57.     }
  58.     #[Route(path'/legal-financiamiento/'name'legal_financing'methods: ['GET'])]
  59.     #[Template('front/legal/legal_financing.html.twig')]
  60.     public function legalFinancingAction(Request $requestLegalFinancingManager $lfmgr): array
  61.     {
  62.         if (!$this->checkIfActive('legal_financing')) {
  63.             throw $this->createNotFoundException('No encontrado');
  64.         }
  65.         $this->locals['home'] = $lfmgr->find(1);
  66.         return $this->locals;
  67.     }
  68.     #[Route(path'/codigo-de-conducta-proveedores/'name'suppliers_code'methods: ['GET'])]
  69.     #[Template('front/legal/suppliers_code.html.twig')]
  70.     public function supplierCodeAction(Request $requestConductaProveedorManager $lppmgr): array
  71.     {
  72.         $info $this->info_mgr->find(1);
  73.         if (!$info->isLinkSupplierCodeShow()) {
  74.             throw $this->createNotFoundException('No encontrado');
  75.         }
  76.         $this->locals['home'] = $lppmgr->find(1);
  77.         return $this->locals;
  78.     }
  79.     protected function checkIfActive($route): bool
  80.     {
  81.         $info $this->info_mgr->find(1);
  82.         $items $info->getFooterLegalLinks();
  83.         $result array_filter($items, fn($e) => $e['show'] && $route == $e['page']);
  84.         return count((array) $result) > 0;
  85.     }
  86. }