Symfony2服务参数(作为表达式语言字符串)

时间:2014-01-28 16:25:24

标签: symfony dependency-injection

正如Symfony2 documentation所描述的那样,可以将“表达式语言”字符串作为服务参数注入,但即使使用简单的实现,它也显然不起作用:

services:
    my_service:
        class:     AAA\BBBBundle\ClassName
        arguments: ["@=container.hasParameter('param_name') ? parameter('param_name') : 'default_value'"]
我得到了:

  

致命错误:未捕获的异常'Symfony \ Component \ DependencyInjection \ Exception \ ServiceNotFoundException',消息'the service“my_service”依赖于不存在的服务“= container.hasparameter('some_param')?parameter(' some_param'):'default_value'“。'在/ [...] / / / / / / / / / / / / / / / /

我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

尝试完全清除app/cache目录