<?php
namespace App\Controller;
use App\Entity\Blog;
use App\Repository\BlogRepository;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class BlogFrontController extends AbstractController
{
/**
* @Route("/blog", name="blog", options={"sitemap" = true})
*/
public function index(BlogRepository $BlogRepository)
{
\date_default_timezone_set('Europe/Paris');
$Blog = $BlogRepository->findBy(
array( 'Publie' => 1 ),
array('Datepublication' => 'DESC')
);
$now = date_create();
return $this->render('blog_front/index.html.twig', [
'controller_name' => 'BlogFrontController',
'Blogs' => $Blog,
'now' => $now
]);
}
/**
* @Route("/blog/{Url}", name="blog_page")
*/
public function blog_page(Blog $Blog=null)
{
if(!$Blog){
$Blog = new Blog();
}
return $this->render('blog_front/voir.html.twig', [
'controller_name' => 'PagesController',
'Blog' => $Blog
]);
}
}