10000 Documented all parameter types by wouterj · Pull Request #2882 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Documented all parameter types #2882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions components/dependency_injection/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

<parameters>
<parameter key="mailer.send_all_in_once">false</parameters>
</parameters>

<!-- after parsing
$container->getParameter('mailer.send_all_in_once'); // returns false
-->

To disable this behaviour, use the ``string`` type:

.. code-block:: xml

<parameters>
<parameter key="mailer.some_parameter" type="string">true</parameter>
</parameters>

<!-- after parsing
$container->getParameter('mailer.some_parameter'); // returns "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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not parameters. Arguments

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
0