Skip to content
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
43 changes: 0 additions & 43 deletions components/dependency_injection/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,49 +140,6 @@ rather than being tied up and hidden with the service definition:
If you were using this elsewhere as well, then you would only need to change
the parameter value in one place if needed.

You can also use the parameters in the service definition, for example,
making the class of a service a parameter:

.. configuration-block::

.. code-block:: yaml

parameters:
mailer.transport: sendmail

services:
mailer:
class: Mailer
arguments: ["%mailer.transport%"]

.. code-block:: xml

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="mailer.transport">sendmail</parameter>
</parameters>

<services>
<service id="mailer" class="Mailer">
<argument>%mailer.transport%</argument>
</service>
</services>
</container>

.. code-block:: php

use Symfony\Component\DependencyInjection\Reference;

$container->setParameter('mailer.transport', 'sendmail');

$container
->register('mailer', 'Mailer')
->addArgument('%mailer.transport%');

.. note::

The percent sign inside a parameter or argument, as part of the string, must
Expand Down