我想要实现的是调用学说 ini TwigExtension
,我从谷歌和 stackoverflow 得到一些代码,如下所示:
服务.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;
}
}
我已经遵循了我的消息来源的所有说明,但是我仍然遇到错误并且无法在这里调用学说或对 entitymanager 执行某些操作。
这是我的错误:
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.
如何解决这个问题?
在service.yml
,而不是doctrine : '@doctrine'
你应该有$doctrine : '@doctrine'
。
你得到的错误试图通过说only integer or $named arguments are allowed
- 注意 **$**named 部分来告诉你这一点。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句