Mohamed Ayoub BENJELLOUN
Mohamed Ayoub BENJELLOUN

Reputation: 1922

Symfony2 service arguments (as an expression language string)

As the Symfony2 documentation describes, it's possible to inject an "expression language" string as a service argument, but it apperently doesn't work, even with a simple implementation :

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

i got:

Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException' with message 'The service "my_service" has a dependency on a non-existent service "=container.hasparameter('some_param') ? parameter('some_param') : 'default_value'".' in /[...]/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php on line 59

have i missed something ?

Upvotes: 2

Views: 1573

Answers (1)

Victor Bocharsky
Victor Bocharsky

Reputation: 12306

Try to clear fully app/cache dir

Upvotes: 1

Related Questions