src/Controller/PaginaController.php line 70

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\General;
  4. use App\Entity\Sidebar;
  5. use App\Entity\Sponsors;
  6. use App\Entity\Usuari;
  7. use App\Entity\Pagina;
  8. use App\Util\Util;
  9. use Doctrine\ORM\EntityManagerInterface;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
  12. use Symfony\Component\HttpFoundation\RequestStack;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  16. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  17. use Symfony\Component\Mailer\MailerInterface;
  18. use Symfony\Component\Security\Core\SecurityContext;
  19. use Symfony\Contracts\Translation\TranslatorInterface;
  20. class PaginaController extends AbstractController
  21. {
  22.     protected $enSidebar;
  23.     protected $enGeneral;
  24.     protected $enSponsors;
  25.     private $em;
  26.     private $objUtil;
  27.     private $requestStack;
  28.     private $session;
  29.     private $translator;
  30.     private $params;
  31.     private $correuController;
  32.     private $mailer;
  33.     private $sPathUploads;
  34.     public function __construct(EntityManagerInterface $em,RequestStack $requestStack,TranslatorInterface $translatorContainerBagInterface $paramsCorreuController $correuController,MailerInterface $mailer)
  35.     {
  36.         $this->em $em;
  37.         $this->objUtil = new Util($this->em);
  38.         $this->requestStack $requestStack;
  39.         $this->session $this->requestStack->getSession();
  40.         $this->translator $translator;
  41.         $this->params $params;
  42.         $this->correuController $correuController;
  43.         $this->mailer $mailer;
  44.         $this->sPathUploads dirname(__FILE__) . "/../../public/uploads/";
  45.         $this->enSidebar $this->em->getRepository(Sidebar::class)->findBy(
  46.             array(   'general' => 1)
  47.         );
  48.         /////////////////////////
  49.         // Recoger dades generals
  50.         /////////////////////////
  51.         $this->enGeneral $this->em->getRepository(General::class)->findAll();
  52.         ///////////
  53.         // Sponsors
  54.         ///////////
  55.         $this->enSponsors $this->em->getRepository(Sponsors::class)->findBy(
  56.             array( 'visible'   => 1),
  57.             array('ordre' => 'ASC')
  58.         );
  59.     }
  60.     public function indexAction(Request $peticion)
  61.     {
  62.         $session $peticion->getSession();
  63.         $session->start();
  64.         
  65.         $repository $this->em->getRepository(Pagina::class);
  66.         
  67.         $pagina $repository->getPaginaSlug($peticion->attributes->get('_slug'), $peticion->attributes->get('_locale'));
  68.         
  69.         $aMetatags = array();
  70.         $aMetatags['title'] = $pagina->{'getTitle' ucfirst($peticion->attributes->get('_locale'))}();
  71.         $aMetatags['description'] = $pagina->{'getDescription' ucfirst($peticion->attributes->get('_locale'))}();
  72.         $aMetatags['keywords'] = $pagina->{'getKeywords' ucfirst($peticion->attributes->get('_locale'))}();
  73.         
  74.         $enPaginaSlug $repository->findOneBy(array("slug_" $peticion->attributes->get('_locale') => $peticion->attributes->get('_slug')));
  75.         
  76.         $blDarrera_hora false;
  77.         if (method_exists('getBlocs'$pagina))
  78.         {
  79.             foreach ($pagina->getBlocs() as $key => $val)
  80.             {
  81.                 //dump ($val->getTipus()->getTipus() );
  82.                 //echo '-' . $val->getTipus()->getSlug() . '<br>';
  83.                 if ($val->getTipus()->getSlug() == 'darrera_hora')
  84.                 {
  85.                     $blDarrera_hora true;
  86.                 }
  87.             }
  88.         }        
  89.         /*
  90.         $objDarreraHora = array();
  91.         if ($blDarrera_hora)
  92.         {
  93.             $aSort = array("data" => "DESC");
  94.             $aParam = array();
  95.             
  96.             $objDarreraHora = $this->em->getRepository(DarreraHora::class)->findBy($aParam,$aSort,5);
  97.             //echo '<pre>';
  98.             //print_r ($objDarreraHora);
  99.             //echo '</pre>';
  100.         }
  101.         $fotos = array();
  102.         if (method_exists('getGaleries',$pagina))
  103.         {
  104.             if (!is_null($pagina->getGaleries()))
  105.             {    
  106.                 $aParam = array('galeries' => $pagina->getGaleries());
  107.                 $fotos = $this->em->getRepository(Fotos::class)->findBy($aParam);
  108.             }
  109.         }
  110.         */
  111.         return $this->render('paginas.html.twig', array(
  112.             'pagina'        => $pagina,
  113.             'esHome'        => 0,
  114.             //'fotos'         => $fotos,
  115.             //'objDarreraHora'=> $objDarreraHora,
  116.             'entMenu'       => $enPaginaSlug,
  117.             'enGeneral'     => $this->enGeneral,
  118.             'enSponsors'    => $this->enSponsors,
  119.             'fotos'         => array(),
  120.             'metatags'      => $aMetatags
  121.         ));
  122.     }
  123.     public function menuListAction($isMobileVersion=false)
  124.     {
  125.         $repository $this->em->getRepository(Pagina::class);
  126.         $list $repository->getSecciones();
  127.         
  128.         return $this->render('menuList.html.twig', array(
  129.             "isMobileVersion"   => $isMobileVersion,
  130.             "list"              => $list
  131.         ));
  132.     }
  133. }