如何为此配置我的服务?
我猜它是这样的:
twig.extension.anyName:
class: Bundle\Twig\RoutingExtension
arguments:
- "twig.extension.routing"
tags:
- { name: twig.extension }
...但它出错:
Catchable Fatal Error: Argument 1 passed to Bundle\Twig\RoutingExtension::__construct() must implement interface Symfony\Component\Routing\Generator\UrlGeneratorInterface, string given...
答案 0 :(得分:1)
引用其他服务的有效语法是@符号,后跟服务名称。目前,您正在将字符串“twig.extension.routing”传递给服务构造函数。
如果您希望将服务实例传递给您的服务,它可能看起来像这样
twig.extension.anyName:
class: Bundle\Twig\RoutingExtension
arguments:
- "@twig.extension.routing"
tags:
- { name: twig.extension }