@@ -68,11 +68,16 @@ If for instance, there is a use case in which you want to use the
68
68
``%kernel.debug% `` debug mode parameter to make your bundle adapt its
69
69
configuration depending on this. For this case you cannot use
70
70
the syntax directly and expect this to work. The configuration handling
71
- will just tread this ``%kernel.debug% `` as a string. Consider
71
+ will just treat this ``%kernel.debug% `` as a string. Consider
72
72
this example with the AcmeDemoBundle::
73
73
74
74
// Inside Configuration class
75
- ->booleanNode('logging')->defaultValue('%kernel.debug%')->end()
75
+ $rootNode
76
+ ->children()
77
+ ->booleanNode('logging')->defaultValue('%kernel.debug%')->end()
78
+ // ...
79
+ ->end()
80
+ ;
76
81
77
82
// Inside the Extension class
78
83
$config = $this->processConfiguration($configuration, $configs);
@@ -102,11 +107,46 @@ Now, examine the results to see this closely:
102
107
103
108
.. code-block :: xml
104
109
105
- I confess i need help here @WouterJ
110
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
111
+ <container xmlns =" http://symfony.com/schema/dic/services"
112
+ my-bundle =" http://example.org/schema/dic/my_bundle" >
113
+
114
+ <my-bundle : config logging =" true" />
115
+ <!-- true, as expected -->
116
+
117
+ <my-bundle : config logging =" %kernel.debug%" />
118
+ <!-- true/false (depends on 2nd parameter of AppKernel),
119
+ as expected, because %kernel.debug% inside configuration
120
+ gets evaluated before being passed to the extension -->
121
+
122
+ <my-bundle : config />
123
+ <!-- passes the string "%kernel.debug%".
124
+ Which is always considered as true.
125
+ The Configurator does not know anything about
126
+ "%kernel.debug%" being a parameter. -->
127
+ </container >
106
128
107
129
.. code-block :: php
108
130
109
- I confess i need help here @WouterJ
131
+ $container->loadFromExtension('my_bundle', array(
132
+ 'logging' => true,
133
+ // true, as expected
134
+ )
135
+ );
136
+
137
+ $container->loadFromExtension('my_bundle', array(
138
+ 'logging' => "%kernel.debug%",
139
+ // true/false (depends on 2nd parameter of AppKernel),
140
+ // as expected, because %kernel.debug% inside configuration
141
+ // gets evaluated before being passed to the extension
142
+ )
143
+ );
144
+
145
+ $container->loadFromExtension('my_bundle');
146
+ // passes the string "%kernel.debug%".
147
+ // Which is always considered as true.
148
+ // The Configurator does not know anything about
149
+ // "%kernel.debug%" being a parameter.
110
150
111
151
In order to support this use case, the ``Configuration `` class has to
112
152
be injected with this parameter via the extension as follows::
0 commit comments