2012-07-03 16:05:09 +00:00
|
|
|
<?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');
|
2012-07-13 10:07:21 +00:00
|
|
|
$news = $newsRepo->findBy(array(), array('createdAt' => 'DESC'), 4);
|
2012-07-03 16:05:09 +00:00
|
|
|
|
|
|
|
return array(
|
|
|
|
'recentNews' => $news,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return 'News';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|