From fc913c0789eb06456ed291c07888a052fc9fb0d9 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Wed, 7 Aug 2013 19:32:44 +0200 Subject: [PATCH] Documented all parameter types --- .../dependency_injection/parameters.rst | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/components/dependency_injection/parameters.rst b/components/dependency_injection/parameters.rst index 129d766cd61..622351c8b71 100644 --- a/components/dependency_injection/parameters.rst +++ b/components/dependency_injection/parameters.rst @@ -264,3 +264,67 @@ key, and define the type as ``constant``. # app/config/config.yml imports: - { resource: parameters.xml } + +PHP keywords in XML +------------------- + +By default, ``true``, ``false`` and ``null`` in XML are converted to the PHP +keywords (respectively ``true``, ``false`` and ``null``): + +.. code-block:: xml + + + false + + + + +To disable this behaviour, use the ``string`` type: + +.. code-block:: xml + + + true + + + + +.. note:: + + This is not available for Yaml and PHP, because they already have built-in + support for the PHP keywords. + +Referencing Services with Parameters +------------------------------------ + +A parameter can also reference to a service. While doing so, it specifies an +invalid behaviour. + +Yaml +~~~~ + +Start the string with ``@``, ``@@`` or ``@?`` to reference a service in Yaml. + +* ``@mailer`` references to the ``mailer`` service. If the service does not + exists, an exception will be thrown; +* ``@?mailer`` references to the ``mailer`` service. If the service does not + exists, it will be ignored; + +Xml +~~~ + +In XML, use the ``service`` type. The behaviour if the service does not exists +can be specified using the ``on-invalid`` argument (it can be set to ``null`` +to return ``null`` or ``ignored`` to let the container ignore the error, if +not specified it throws an exception). + +Php +~~~ + +In PHP, you can use the +:class:`Symfony\\Component\\DependencyInjection\\Reference` class to reference +a service.