0

如何为此配置我的服务?

https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php

我猜它是这样的:

  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...
4

1 回答 1

1

引用其他服务的有效语法是 @ 符号后跟服务名称。目前,您正在将字符串“twig.extension.routing”传递给您的服务构造函数。

如果您想将服务实例传递给您的服务,它可能看起来像这样

 twig.extension.anyName:
    class: Bundle\Twig\RoutingExtension
    arguments:
      - "@twig.extension.routing"
    tags:
      - { name: twig.extension }
于 2013-03-29T16:23:49.907 回答