symfony/DependencyInjection — pull request #2 by avorobiev (2012-06-20 12:58:17+00:00)
Title: Problem with unescaping class arguments

I've got an error when I tried to use DI to initiate Monolog logger with next settings:

services:
logger_formatter:
class: \Monolog\Formatter\LineFormatter
arguments: [ "[%%datetime%%] %%channel%%.%%level_name%%: %%message%% %%context%%\n" ]

logger_handler:
class: \Monolog\Handler\StreamHandler
arguments:
- app.log
-
calls:
- [ setFormatter, [ @logger_formatter ]]

logger:
class: \Monolog\Logger
arguments: [ 'logger_name' ]
calls:
- [ pushHandler, [ @logger_handler ]]

If I set argument for service logger_formatter with single % (like “"[%datetime%]…”) then DI threw exception that it could not resolve reference because there was non-existent parameter "datetime".
If I set argument with double % (like “"[%%datetime%%]…”) then DI transferred parameter to the LineFormatter object without unescaping, and LineFormatter did not work properly.
The problem was in ContainerBuilder, because there was no unescaping class parameters.

I’ve fixed problem and added tests to cover such case.