8000 [Cookbook][Configuration] add configuration cookbook handlig parameters in Configurator class by cordoval · Pull Request #3420 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Cookbook][Configuration] add configuration cookbook handlig parameters in Configurator class #3420

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
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
address weaverryan comments
  • Loading branch information
cordoval committed Jan 10, 2014
commit a6bda5e6a17a80dae5e90fc4d526e6082a55108b
2 changes: 1 addition & 1 deletion cookbook/bundles/extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The second method has several specific advantages:
.. seealso::

For other usages of the parameter ``%`` syntax see
:doc:`Using Configuration Parameters </cookbook/using_configuration_parameters>`.
:doc:`Using Parameters Within A Dependency Injection Class </cookbook/using_parameters_in_dic>`.
Copy link
Member

Choose a reason for hiding this comment

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

You don't have to use the title here:

:doc:`</cookbook/using_parameters_in_dic>`.

Copy link
Member

Choose a reason for hiding this comment

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

Additionally, the document is located at ``/cookbook/configuration/using_parameters_in_dic`.


.. index::
single: Bundle; Extension
Expand Down
2 changes: 1 addition & 1 deletion cookbook/configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Configuration

environments
override_dir_structure
using_configuration_parameters
using_parameters_in_dic
front_controllers_and_kernel
external_parameters
pdo_session_storage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,75 +1,17 @@
.. index::
single: Using Configuration Parameters

Using Configuration Parameters
==============================

Parameters, such as ``kernel.root_dir`` (pointing to a path) or ``kernel.debug``
(whether debug mode is enabled), are common in configuration. By wrapping the
parameter name within 2 ``%`` characters, you indicate that this value should
be replaced by the value of the parameter. When using Symfony, you can have
parameters defined in a bundle and used only in that bundle and also parameters
defined in a bundle and used in another. Usually they would have a name
like ``demo_bundle.service_doer.local_parameter`` making explicit where this
parameter comes from. If the parameter is global then it may not have a
namespace, e.g. ``%some_global_option_here%``.

Basic Usage
-----------

You can use parameters inside the ``parameters.yml`` file:

.. code-block:: yaml

# app/config/parameters.yml
parameters:
payment_test_mode: "%kernel.root_dir%"

Inside ``config.yml`` and other configuration files building larger
strings:

.. configuration-block::

.. code-block:: yaml

# app/config/config.yml
my_bundle:
local:
directory: "%kernel.root_dir%/../web/media/image"

.. code-block:: xml

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
my-bundle="http://example.org/schema/dic/my_bundle">
<my-bundle:config>
<my-bundle:local directory="%kernel.root_dir%/../web/media/image" />
</my-bundle:config>
</container>

.. code-block:: php

$container->loadFromExtension('my_bundle', array(
'local' => array(
'directory' => '%kernel.root_dir%/../web/media/image',
),
));

For more information on how parameters are used in Symfony please see
:ref:`parameters <book-service-container-parameters>`.

Besides these usages above you can use this syntax in routing files and handle
parameters in special cases as discussed below.

Using Parameters in your Bundle Configuration
---------------------------------------------

If for instance, there is a use case in which you want to use the
``%kernel.debug%`` debug mode parameter to make your bundle adapt its
configuration depending on this. For this case you cannot use
the syntax directly and expect this to work. The configuration handling
will just treat this ``%kernel.debug%`` as a string. Consider
this example with the AcmeDemoBundle::
single: Using Parameters Within A Dependency Injection Class

Using Parameters Within A Dependency Injection Class
Copy link
Member

Choose a reason for hiding this comment

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

I think Using Parameters within a Dependency Injection Class is correct.

----------------------------------------------------

You have seen how to use configuration parameters within
:ref:`Symfony service container <book-service-container-parameters>`.
8000
Copy link
Member

Choose a reason for hiding this comment

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

Symfony service containers (plural)

There are special cases such as when you want, for instance, to use the
``%kernel.debug%`` parameter to make the services in your bundle enter
debug mode. For this case there is more work to do in order
to make the system understand the parameter value. By default
your parameter ``%kernel.debug%`` will be treated as a
simple string. Consider this example with the AcmeDemoBundle::

// Inside Configuration class
$rootNode
Expand Down
1 change: 1 addition & 0 deletions cookbook/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

* :doc:`/cookbook/configuration/environments`
* :doc:`/cookbook/configuration/override_dir_structure`
* :doc:`/cookbook/configuration/using_parameters_in_dic`
* :doc:`/cookbook/configuration/front_controllers_and_kernel`
* :doc:`/cookbook/configuration/external_parameters`
* :doc:`/cookbook/configuration/pdo_session_storage`
Expand Down
2 changes: 1 addition & 1 deletion cookbook/routing/service_container_parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ path):
.. seealso::

For other usages of the parameter ``%`` syntax see
:doc:`Using Configuration Parameters </cookbook/using_configuration_parameters>`.
:doc:`Using Parameters Within A Dependency Injection Class </cookbook/using_parameters_in_dic>`.
Copy link
Member

Choose a reason for hiding this comment

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

You don't have to use the title here:

:doc:`</cookbook/using_parameters_in_dic>`.

Copy link
Member

Choose a reason for hiding this comment

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

Additionally, the document is located at ``/cookbook/configuration/using_parameters_in_dic`.

0