Added basic blog functionality

Signed-off-by: Gergely Polonkai (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely Polonkai (W00d5t0ck)
2012-09-04 13:09:32 +02:00
parent ea325aab7f
commit 5bcd9f079b
17 changed files with 412 additions and 21 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace GergelyPolonkai\FrontBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use GergelyPolonkai\FrontBundle\Entity\Post;
/**
* Description of BlogController
*
* @author polonkai.gergely
*/
class BlogController extends Controller
{
/**
* @Route("/blog/{year}/{month}/{day}/{slug}.html", name="GergelyPolonkaiFront_blogViewPost")
* @Template
*/
public function viewPostAction($year, $month, $day, $slug)
{
$date = new \DateTime();
$date->setDate($year, $month, $day);
$date->setTime(0, 0, 0);
$date2 = new \DateTime();
$date2->setDate($year, $month, $day);
$date2->setTime(0, 0, 0);
$date2->add(new \DateInterval('P1D'));
$query = $this->getDoctrine()->getEntityManager()->createQuery("SELECT p FROM GergelyPolonkaiFrontBundle:Post p WHERE p.slug = :slug AND p.createdAt BETWEEN :date1 AND :date2");
$query->setParameter(':slug', $slug);
$query->setParameter(':date1', $date);
$query->setParameter(':date2', $date2);
$post = $query->getOneOrNullResult();
return array(
'post' => $post,
);
}
}