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