我想要实现的是调用doctrine ini service.yml p>
AppBundle \ Twig \ AppEtension.php p>
我已经遵循了我的来源的所有说明,但我仍然有错误,无法调用教条或在这里使用entitymanager做一些事情。 p>
这是我的错误: p> \ ñ
如何解决这个问题? p>
div> TwigExtension code>,我从google获取了一些代码 stackoverflow,如下所示: p>
twig.extension:
class:AppBundle \ Twig \ AppExtension
arguments:
doctrine:'@ doctrine'
tags:
- {name:twig.extension}
code> pre>
<?php
namespace AppBundle \ Twig;
use Symfony \ Bridge \ Doctrine \ RegistryInterface;
class AppExtension extends \ Twig_Extension
{
protected $ doctrine ;
公共函数__construct(RegistryInterface $ doctrine)
{
$ this-> doctrine = $ doctrine;
}
}
code> pre>
<代码>的Symfony \元器件\ DependencyInjection \异常\无效 ArgumentException]
在服务“twig.extension”的方法“__construct()”的参数中找到无效的密钥“doctrine”:只允许整数或$ named参数。
code> pre>
What I want achieve is call doctrine ini TwigExtension
, I get some code from google and stackoverflow, like this :
service.yml
twig.extension:
class: AppBundle\Twig\AppExtension
arguments:
doctrine : '@doctrine'
tags:
- { name: twig.extension }
AppBundle\Twig\AppEtension.php
<?php
namespace AppBundle\Twig;
use Symfony\Bridge\Doctrine\RegistryInterface;
class AppExtension extends \Twig_Extension
{
protected $doctrine;
public function __construct(RegistryInterface $doctrine)
{
$this->doctrine = $doctrine;
}
}
I've followed all instruction from my source, but i still got error and cant call doctrine or do something with entitymanager here.
this is my error :
Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
Invalid key "doctrine" found in arguments of method "__construct()" for service "twig.extension": only integer or $named arguments are allowed.
how to solve this?