src/Controller/BlogFrontController.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Blog;
  4. use App\Repository\BlogRepository;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. class BlogFrontController extends AbstractController
  8. {
  9.     /**
  10.      * @Route("/blog", name="blog", options={"sitemap" = true})
  11.      */
  12.     public function index(BlogRepository $BlogRepository)
  13.     {
  14.         \date_default_timezone_set('Europe/Paris'); 
  15.         $Blog $BlogRepository->findBy(
  16.             array( 'Publie' => ),
  17.             array('Datepublication' => 'DESC')
  18.         );
  19.         $now date_create();
  20.         return $this->render('blog_front/index.html.twig', [
  21.             'controller_name' => 'BlogFrontController',
  22.             'Blogs' => $Blog,
  23.             'now' => $now
  24.         ]);
  25.     }
  26.     /**
  27.      * @Route("/blog/{Url}", name="blog_page")
  28.      */
  29.     public function blog_page(Blog $Blog=null)
  30.     {
  31.         if(!$Blog){
  32.             $Blog = new Blog();
  33.         } 
  34.         return $this->render('blog_front/voir.html.twig', [
  35.             'controller_name' => 'PagesController',
  36.             'Blog' => $Blog
  37.         ]);
  38.     }
  39. }