src/Controller/BlogController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Utils\BlogService;
  4. use ReCaptcha\ReCaptcha;
  5. use ReCaptcha\RequestMethod\CurlPost;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. class BlogController extends AbstractController
  10. {
  11.     private $blogService;
  12.     public function __construct(BlogService $blogService)
  13.     {
  14.         $this->blogService $blogService;
  15.     }
  16.     public function index($page)
  17.     {
  18.         //Metaetiquetas para la pagina principal
  19.         $url 'listadoblog';
  20.         //seo on page
  21.         $seo_on_page $this->blogService->DevolverSeoOnPage($url);
  22.         // listar
  23.         $anuncios $this->blogService->ListarBlogs($page);
  24.         return $this->render('frontend/blog/index.html.twig', array(
  25.             'seo_on_page' => $seo_on_page,
  26.             'anuncios' => $anuncios,
  27.             'ruta' => 'listadoblog',
  28.             'parametro_ruta' => null,
  29.         ));
  30.     }
  31.     public function detalle($url)
  32.     {
  33.         $anuncio $this->blogService->DetalleBlog($url);
  34.         if (!empty($anuncio)) {
  35.             return $this->render('frontend/blog/detalle.html.twig', array(
  36.                 'anuncio' => $anuncio
  37.             ));
  38.         } else {
  39.             return $this->redirectToRoute('error404');
  40.         }
  41.     }
  42. }