<?php
namespace App\Controller\Publico;
use App\Entity\Ajustes\Pagina;
use App\Repository\Ajustes\PaginaRepository;
use App\Repository\Ajustes\SliderRepository;
use App\Utils\FilterSession;
use App\Utils\HelperUtil;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sonata\SeoBundle\Seo\SeoPageInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
use WhiteOctober\BreadcrumbsBundle\Model\Breadcrumbs;
/**
* @Route("/", name="pagina_")
*/
class PaginaController extends AbstractController
{
public const BASEDIR = Pagina::BASEDIR;
public const ICON = Pagina::ICON;
protected $em;
protected $bd;
protected $bag;
protected $pag;
protected $hlp;
protected $repo;
protected $trans;
protected $seo;
public function __construct(EntityManagerInterface $em, Breadcrumbs $bd, PaginatorInterface $pg, PaginaRepository $repo, HelperUtil $hlp, ParameterBagInterface $pb, TranslatorInterface $trans, SeoPageInterface $seo)
{
$this->em = $em;
$this->bd = $bd;
$this->bag = $pb;
$this->pag = $pg;
$this->repo = $repo;
$this->hlp = $hlp;
$this->trans = $trans;
$this->seo = $seo;
}
/**
* @Route("/{PagSlug}.html", name="view", methods = {"DELETE", "GET", "POST"}, requirements = {"PagSlug"="[\w-]+"}, options={"expose"=true})
*
* @param mixed $force
*/
public function view(Pagina $entity): Response
{
//SEO
$titulo = $entity->getPagTitulo() != null ? $entity->getPagTitulo() : "";
$descripcion = $entity->getPagMetaDescripcion() != null ? $entity->getPagMetaDescripcion() : "";
$this->seo
->setTitle($titulo)
->addMeta('name', 'description', $descripcion)
->addMeta('property', 'og:title', $titulo)
->addMeta('property', 'og:description', $descripcion)
;
return $this->render(self::BASEDIR.'/pag_view.html.twig', [
'pag' => $entity,
'BaseDir' => self::BASEDIR,
'ICON' => self::ICON,
]);
}
}