Now fetching news from the database

This commit is contained in:
Polonkai Gergely
2012-07-03 18:05:09 +02:00
parent 8b0e8e1a29
commit 20fea814e4
6 changed files with 325 additions and 30 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace KekRozsak\FrontBundle\Twig;
use Symfony\Bridge\Doctrine\RegistryInterface;
class NewsExtension extends \Twig_Extension
{
protected $doctrine;
public function __construct(RegistryInterface $doctrine)
{
$this->doctrine = $doctrine;
}
public function getGlobals()
{
$newsRepo = $this->doctrine->getRepository('KekRozsakFrontBundle:News');
$news = $newsRepo->findBy(array(), array('created_at' => 'DESC'), 4);
return array(
'recentNews' => $news,
);
}
public function getName()
{
return 'News';
}
}