22 single: Dependency Injection; Parameters
33
44Introduction to Parameters
5- =================================
5+ ==========================
66
77You can define parameters in the service container which can then be used
88directly or as part of service definitions. This can help to separate out
@@ -11,13 +11,13 @@ values that you will want to change more regularly.
1111Getting and Setting Container Parameters
1212----------------------------------------
1313
14- Working with container parameters isstraight forward using the container's
14+ Working with container parameters isstraightforward using the container's
1515accessor methods for parameters. You can check if a parameter has been defined
1616in the container with::
1717
1818 $container->hasParameter('mailer.transport');
1919
20- You can retrieveparameters set in the container with::
20+ You can retrievea parameter set in the container with::
2121
2222 $container->getParameter('mailer.transport');
2323
@@ -29,7 +29,7 @@ and set a parameter in the container with::
2929
3030 You can only set a parameter before the container is compiled. To learn
3131 more about compiling the container see
32- :doc: `/components/dependency_injection/compilation `
32+ :doc: `/components/dependency_injection/compilation `.
3333
3434Parameters in Configuration Files
3535---------------------------------
@@ -54,14 +54,14 @@ You can also use the ``parameters`` section of a config file to set parameters:
5454 $container->setParameter('mailer.transport', 'sendmail');
5555
5656 As well as retrieving the parameter values directly from the container you
57- can use them in the config files. You can refer to parameters elsewherein
58- the config files by surrounding them with percent (``% ``) signs, e.g.
59- `` %mailer.transport% ``. One useis for this is to inject the values into your
60- services. This allows you to configure different versions of services between
61- applications or multiple services based on the same class but configured
62- differently within a single application. You could inject the choice of mail
63- transport into the `` Mailer `` class directly but by making it a parameter it
64- makes it easier to change rather than being tied up with the service definition:
57+ can use them in the config files. You can refer to parameters elsewhereby
58+ surrounding them with percent (``% ``) signs, e.g. `` %mailer.transport% `` .
59+ One use for this is to inject the values into your services. This allows
60+ you to configure different versions of services between applications or multiple
61+ services based on the same class but configured differently within a single
62+ application. You could inject the choice of mail transport into the `` Mailer ``
63+ class directly but by making it a parameter. This makes it easier to change
64+ rather than being tied up and hidden with the service definition:
6565
6666..configuration-block ::
6767
@@ -97,8 +97,8 @@ makes it easier to change rather than being tied up with the service definition:
9797 ->register('mailer', 'Mailer')
9898 ->addArgument('%mailer.transport%');
9999
100- Ifwe were using this elsewhere as well, thenit would only needchanging
101- in one place ifa different transport was required .
100+ Ifyou were using this elsewhere as well, thenyou would only needto change
101+ the parameter value in one place ifneeded .
102102
103103You can also use the parameters in the service definition, for example,
104104making the class of a service a parameter:
@@ -164,6 +164,8 @@ making the class of a service a parameter:
164164
165165 ->addArgument('http://symfony.com/?foo=%%s&bar=%%d');
166166
167+ .. _component-di-parameters-array :
168+
167169Array Parameters
168170----------------
169171
@@ -221,6 +223,8 @@ arrays.
221223 'fr' => array('fr', 'en'),
222224 ));
223225
226+ .. _component-di-parameters-constants :
227+
224228Constants as Parameters
225229-----------------------
226230