src/Controller/ContenidoController.php line 35

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  9. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  10. use Symfony\Contracts\Translation\TranslatorInterface;
  11. use Doctrine\ORM\EntityManagerInterface;
  12. use Knp\Component\Pager\PaginatorInterface;
  13. use Symfony\Component\HttpFoundation\Cookie;
  14. use Symfony\Component\HttpFoundation\RequestStack;
  15. use Doctrine\Persistence\ManagerRegistry as PersistenceManagerRegistry;
  16. use Symfony\Component\Cache\Adapter\FilesystemAdapter;
  17. use Symfony\Contracts\Cache\ItemInterface;
  18. use App\Entity\Contenido;
  19. use App\Services\ConfigurationManager;
  20. use App\Services\SettingsManager;
  21. class ContenidoController extends AbstractController
  22. {
  23.     #[Route(path: [
  24.         'es' => '/cms/{slug}',
  25.         'en' => '/en/cms/{slug}'
  26.     ], name'cms')]
  27.     public function pagina(Request $request,PersistenceManagerRegistry $doctrine$slug$_localeTranslatorInterface $translator): Response
  28.     {
  29.         $id Contenido::getSlugId($slug);
  30.         $em $doctrine->getManager();
  31.         $contenido false;
  32.         $promociones = [];
  33.         
  34.         if ($id) {
  35.             if ($this->getUser() and (in_array('ROLE_ADMIN'$this->getUser()->getRoles(), true) or in_array('ROLE_SUPER_ADMIN'$this->getUser()->getRoles(), true))) 
  36.                 $contenido $em->getRepository('App\Entity\Contenido')->ContenidoByIdIdiomaTipoQuery($id,$_locale,Contenido::TIPO_PAGINA,false,true);
  37.             else
  38.                 $contenido $em->getRepository('App\Entity\Contenido')->ContenidoByIdIdiomaTipoQuery($id,$_locale,Contenido::TIPO_PAGINA);
  39.         }
  40.         if (!$contenido)
  41.             throw $this->createNotFoundException('No existe la página');
  42.             
  43.         
  44.        
  45.         switch($contenido->getClave()) {
  46.         
  47.             case 'contacto':
  48.                 $template 'default/cms/contacto.html.twig';
  49.             break;
  50.             case 'afiliados':
  51.                 $template 'default/cms/afiliados.html.twig';
  52.             break;
  53.             case 'anunciantes':
  54.                 $template 'default/cms/anunciantes.html.twig';
  55.             break;
  56.             case 'ser_agente':
  57.                 $template 'default/cms/ser_agente.html.twig';
  58.             break;
  59.             case 'rrhh':
  60.                 $template 'default/cms/rrhh.html.twig';
  61.             break;
  62.             case 'club':
  63.                 $template 'default/cms/club.html.twig';
  64.                 $promociones =  $em->getRepository('App\Entity\Promocion')->findByActiva(true);
  65.             break;
  66.             default:
  67.                 $template 'default/cms.html.twig';
  68.         }
  69.         
  70.         $response $this->render($template, [
  71.             'contenido' => $contenido,
  72.             'promociones' => $promociones
  73.         ]);
  74.         
  75.         
  76.         return $response;
  77.     }
  78.     
  79.    
  80.     
  81. }