src/Controller/Publico/PaginaController.php line 57

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Publico;
  3. use App\Entity\Ajustes\Pagina;
  4. use App\Repository\Ajustes\PaginaRepository;
  5. use App\Repository\Ajustes\SliderRepository;
  6. use App\Utils\FilterSession;
  7. use App\Utils\HelperUtil;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Knp\Component\Pager\PaginatorInterface;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  11. use Sonata\SeoBundle\Seo\SeoPageInterface;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  14. use Symfony\Component\HttpFoundation\RedirectResponse;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\Response;
  17. use Symfony\Component\Routing\Annotation\Route;
  18. use Symfony\Contracts\Translation\TranslatorInterface;
  19. use WhiteOctober\BreadcrumbsBundle\Model\Breadcrumbs;
  20. /**
  21.  * @Route("/", name="pagina_")
  22.  */
  23. class PaginaController extends AbstractController
  24. {
  25.     public const BASEDIR Pagina::BASEDIR;
  26.     public const ICON Pagina::ICON;
  27.     protected $em;
  28.     protected $bd;
  29.     protected $bag;
  30.     protected $pag;
  31.     protected $hlp;
  32.     protected $repo;
  33.     protected $trans;
  34.     protected $seo;
  35.     public function __construct(EntityManagerInterface $emBreadcrumbs $bdPaginatorInterface $pgPaginaRepository $repoHelperUtil $hlpParameterBagInterface $pbTranslatorInterface $transSeoPageInterface $seo)
  36.     {
  37.         $this->em $em;
  38.         $this->bd $bd;
  39.         $this->bag $pb;
  40.         $this->pag $pg;
  41.         $this->repo $repo;
  42.         $this->hlp $hlp;
  43.         $this->trans $trans;
  44.         $this->seo $seo;
  45.     }
  46.     /**
  47.      * @Route("/{PagSlug}.html", name="view", methods = {"DELETE", "GET", "POST"}, requirements = {"PagSlug"="[\w-]+"}, options={"expose"=true})
  48.      *
  49.      * @param mixed $force
  50.      */
  51.     public function view(Pagina $entity): Response
  52.     {
  53.         //SEO
  54.         $titulo $entity->getPagTitulo() != null $entity->getPagTitulo() : "";
  55.         $descripcion $entity->getPagMetaDescripcion() != null $entity->getPagMetaDescripcion() : "";
  56.         $this->seo 
  57.             ->setTitle($titulo)
  58.             ->addMeta('name''description'$descripcion)
  59.             ->addMeta('property''og:title'$titulo)
  60.             ->addMeta('property''og:description'$descripcion)
  61.         ;
  62.         return $this->render(self::BASEDIR.'/pag_view.html.twig', [
  63.             'pag' => $entity,
  64.             'BaseDir' => self::BASEDIR,
  65.             'ICON' => self::ICON,
  66.         ]);
  67.     }
  68. }