Now fetching news from the database
This commit is contained in:
31
src/KekRozsak/FrontBundle/Twig/NewsExtension.php
Normal file
31
src/KekRozsak/FrontBundle/Twig/NewsExtension.php
Normal 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';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user