Попытался вытащить сущности с помощью twig extension, но ничего не выходит.
класс сервиса:
<?php
namespace NT\MainBundle\Twig\Extension;
use Doctrine\Common\Persistence\ObjectManager;
class ShopExtension extends \Twig_Extension
{
protected $em;
public function __construct(ObjectManager $em)
{
$this->em = $em;
}
public function getName()
{
return 'shop_extension';
}
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('get_shops', array($this, 'getShops'))
);
}
public function getShops()
{
return $this->em->getRepository('NTMainBundle:Shop')->findAll();
}
}
services.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="shop.class">NT\MainBundle\Twig\Extension\ShopExtension</parameter>
</parameters>
<services>
<service id="twig.extension.nt.main_bundle.shop_extension" class="%shop.class%">
<argument type="service" id="doctrine.orm.entity_manager"/>
</service>
</services>
</container>
при вызове
get_shops()
в шаблоне, выдает
The function "get_shops" does not exist in ::base.html.twig
что я делаю не так?