I'm trying to call some data in my root twig template and used Twig global variables to achieve that.
When I call the service i get this error:
Type error: Argument 1 passed to AwarenessBundle\Service\AwarenessService::getLatestNews() must implement interface Doctrine\ORM\EntityManagerInterface, none given, called in /var/www/html/myisms/vendor/twig/twig/lib/Twig/Template.php on line 675
Twig code:
{{ news_service.getlatestNews() }}
services.yml:
news.latest:
class: AwarenessBundle\Service\AwarenessService
arguments: [ '@doctrine.orm.entity_manager' ]
AwarenessService
class AwarenessService
{
public function getLatestNews(EntityManagerInterface $em)
{
return $em->getRepository("AwarenessBundle:Feed")
->findBy(array(), array('id' => 'DESC', 10));
}
}
I'm not sure where my problem is but I have to make my service global and I don't know how to do that. Any help would be appreciated.