@@ -264,3 +264,67 @@ key, and define the type as ``constant``.
264
264
# app/config/config.yml
265
265
imports :
266
266
- { resource: parameters.xml }
267
+
268
+ PHP keywords in XML
269
+ -------------------
270
+
271
+ By default, ``true ``, ``false `` and ``null `` in XML are converted to the PHP
272
+ keywords (respectively ``true ``, ``false `` and ``null ``):
273
+
274
+ .. code-block :: xml
275
+
276
+ <parameters >
277
+ <parameter key =" mailer.send_all_in_once" >false</parameters >
278
+ </parameters >
279
+
280
+ <!-- after parsing
281
+ $container->getParameter('mailer.send_all_in_once'); // returns false
282
+ -->
283
+
284
+ To disable this behaviour, use the ``string `` type:
285
+
286
+ .. code-block :: xml
287
+
288
+ <parameters >
289
+ <parameter key =" mailer.some_parameter" type =" string" >true</parameter >
290
+ </parameters >
291
+
292
+ <!-- after parsing
293
+ $container->getParameter('mailer.some_parameter'); // returns "true"
294
+ -->
295
+
296
+ .. note ::
297
+
298
+ This is not available for Yaml and PHP, because they already have built-in
299
+ support for the PHP keywords.
300
+
301
+ Referencing Services with Parameters
302
+ ------------------------------------
303
+
304
+ A parameter can also reference to a service. While doing so, it specifies an
305
+ invalid behaviour.
306
+
307
+ Yaml
308
+ ~~~~
309
+
310
+ Start the string with ``@ ``, ``@@ `` or ``@? `` to reference a service in Yaml.
311
+
312
+ * ``@mailer `` references to the ``mailer `` service. If the service does not
313
+ exists, an exception will be thrown;
314
+ * ``@?mailer `` references to the ``mailer `` service. If the service does not
315
+ exists, it will be ignored;
316
+
317
+ Xml
318
+ ~~~
319
+
320
+ In XML, use the ``service `` type. The behaviour if the service does not exists
321
+ can be specified using the ``on-invalid `` argument (it can be set to ``null ``
322
+ to return ``null `` or ``ignored `` to let the container ignore the error, if
323
+ not specified it throws an exception).
324
+
325
+ Php
326
+ ~~~
327
+
328
+ In PHP, you can use the
329
+ :class: `Symfony\\ Component\\ DependencyInjection\\ Reference ` class to reference
330
+ a service.
0 commit comments