Skip to content

Commit a6bda5e

Browse files
committed
address weaverryan comments
1 parent 28c144a commit a6bda5e

File tree

5 files changed

+17
-74
lines changed

5 files changed

+17
-74
lines changed

cookbook/bundles/extension.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The second method has several specific advantages:
9292
.. seealso::
9393

9494
For other usages of the parameter ``%`` syntax see
95-
:doc:`Using Configuration Parameters </cookbook/using_configuration_parameters>`.
95+
:doc:`Using Parameters Within A Dependency Injection Class </cookbook/using_parameters_in_dic>`.
9696

9797
.. index::
9898
single: Bundle; Extension

cookbook/configuration/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Configuration
66

77
environments
88
override_dir_structure
9-
using_configuration_parameters
9+
using_parameters_in_dic
1010
front_controllers_and_kernel
1111
external_parameters
1212
pdo_session_storage

cookbook/configuration/using_configuration_parameters.rst renamed to cookbook/configuration/using_parameters_in_dic.rst

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,17 @@
11
.. index::
2-
single: Using Configuration Parameters
3-
4-
Using Configuration Parameters
5-
==============================
6-
7-
Parameters, such as ``kernel.root_dir`` (pointing to a path) or ``kernel.debug``
8-
(whether debug mode is enabled), are common in configuration. By wrapping the
9-
parameter name within 2 ``%`` characters, you indicate that this value should
10-
be replaced by the value of the parameter. When using Symfony, you can have
11-
parameters defined in a bundle and used only in that bundle and also parameters
12-
defined in a bundle and used in another. Usually they would have a name
13-
like ``demo_bundle.service_doer.local_parameter`` making explicit where this
14-
parameter comes from. If the parameter is global then it may not have a
15-
namespace, e.g. ``%some_global_option_here%``.
16-
17-
Basic Usage
18-
-----------
19-
20-
You can use parameters inside the ``parameters.yml`` file:
21-
22-
.. code-block:: yaml
23-
24-
# app/config/parameters.yml
25-
parameters:
26-
payment_test_mode: "%kernel.root_dir%"
27-
28-
Inside ``config.yml`` and other configuration files building larger
29-
strings:
30-
31-
.. configuration-block::
32-
33-
.. code-block:: yaml
34-
35-
# app/config/config.yml
36-
my_bundle:
37-
local:
38-
directory: "%kernel.root_dir%/../web/media/image"
39-
40-
.. code-block:: xml
41-
42-
<?xml version="1.0" encoding="UTF-8" ?>
43-
<container xmlns="http://symfony.com/schema/dic/services"
44-
my-bundle="http://example.org/schema/dic/my_bundle">
45-
<my-bundle:config>
46-
<my-bundle:local directory="%kernel.root_dir%/../web/media/image" />
47-
</my-bundle:config>
48-
</container>
49-
50-
.. code-block:: php
51-
52-
$container->loadFromExtension('my_bundle', array(
53-
'local' => array(
54-
'directory' => '%kernel.root_dir%/../web/media/image',
55-
),
56-
));
57-
58-
For more information on how parameters are used in Symfony please see
59-
:ref:`parameters <book-service-container-parameters>`.
60-
61-
Besides these usages above you can use this syntax in routing files and handle
62-
parameters in special cases as discussed below.
63-
64-
Using Parameters in your Bundle Configuration
65-
---------------------------------------------
66-
67-
If for instance, there is a use case in which you want to use the
68-
``%kernel.debug%`` debug mode parameter to make your bundle adapt its
69-
configuration depending on this. For this case you cannot use
70-
the syntax directly and expect this to work. The configuration handling
71-
will just treat this ``%kernel.debug%`` as a string. Consider
72-
this example with the AcmeDemoBundle::
2+
single: Using Parameters Within A Dependency Injection Class
3+
4+
Using Parameters Within A Dependency Injection Class
5+
----------------------------------------------------
6+
7+
You have seen how to use configuration parameters within
8+
:ref:`Symfony service container <book-service-container-parameters>`.
9+
There are special cases such as when you want, for instance, to use the
10+
``%kernel.debug%`` parameter to make the services in your bundle enter
11+
debug mode. For this case there is more work to do in order
12+
to make the system understand the parameter value. By default
13+
your parameter ``%kernel.debug%`` will be treated as a
14+
simple string. Consider this example with the AcmeDemoBundle::
7315

7416
// Inside Configuration class
7517
$rootNode

cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
* :doc:`/cookbook/configuration/environments`
2626
* :doc:`/cookbook/configuration/override_dir_structure`
27+
* :doc:`/cookbook/configuration/using_parameters_in_dic`
2728
* :doc:`/cookbook/configuration/front_controllers_and_kernel`
2829
* :doc:`/cookbook/configuration/external_parameters`
2930
* :doc:`/cookbook/configuration/pdo_session_storage`

cookbook/routing/service_container_parameters.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ path):
124124
.. seealso::
125125

126126
For other usages of the parameter ``%`` syntax see
127-
:doc:`Using Configuration Parameters </cookbook/using_configuration_parameters>`.
127+
:doc:`Using Parameters Within A Dependency Injection Class </cookbook/using_parameters_in_dic>`.

0 commit comments

Comments
 (0)