From 79191bfc5b2b3e30296527fe7e81d4855f4a46c6 Mon Sep 17 00:00:00 2001 From: Michael COULLERET Date: Wed, 22 Feb 2017 15:46:36 +0100 Subject: [PATCH 1/3] [DependencyInjection][Improve] Constant YAML with expression language] --- service_container/parameters.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/service_container/parameters.rst b/service_container/parameters.rst index 0c1890e3dfd..50c5b2e84c9 100644 --- a/service_container/parameters.rst +++ b/service_container/parameters.rst @@ -225,6 +225,12 @@ key and define the type as ``constant``. .. configuration-block:: + .. code-block:: yaml + + parameters: + global.constant.value: "@=constant('GLOBAL_CONSTANT')" + my_class.constant.value: "@=constant('My_Class::CONSTANT_NAME')" + .. code-block:: xml @@ -243,6 +249,12 @@ key and define the type as ``constant``. $container->setParameter('global.constant.value', GLOBAL_CONSTANT); $container->setParameter('my_class.constant.value', My_Class::CONSTANT_NAME); +.. caution:: + + It's also possible to use PHP constants in YAML files using expression language. + You must have :doc:`/components/expression_language` installed. + To learn more about the expression language syntax, see :doc:`/components/expression_language/syntax`. + .. tip:: If you're using YAML, you can :doc:`import an XML file ` @@ -253,6 +265,10 @@ key and define the type as ``constant``. imports: - { resource: parameters.xml } +.. note:: + + In Symfony 3.2 YAML support PHP constants. + PHP Keywords in XML ------------------- From 6d0de9dcdec03a829334dfa0a7f5ba0cc176847b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 22 Feb 2017 15:58:16 +0100 Subject: [PATCH 2/3] Minor rewords --- service_container/parameters.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/service_container/parameters.rst b/service_container/parameters.rst index 50c5b2e84c9..77d77240dca 100644 --- a/service_container/parameters.rst +++ b/service_container/parameters.rst @@ -251,9 +251,10 @@ key and define the type as ``constant``. .. caution:: - It's also possible to use PHP constants in YAML files using expression language. - You must have :doc:`/components/expression_language` installed. - To learn more about the expression language syntax, see :doc:`/components/expression_language/syntax`. + YAML files can refer to PHP constants via the ``@=constant('CONSTANT_NAME')`` + syntax, which is provided by the + :doc:`Expression Language component /components/expression_language`. See + :doc:`/components/expression_language/syntax` to learn more about its syntax. .. tip:: @@ -267,7 +268,7 @@ key and define the type as ``constant``. .. note:: - In Symfony 3.2 YAML support PHP constants. +   In Symfony 3.2, YAML supports PHP constants via the ``!php/const:CONSTANT_NAME`` syntax. PHP Keywords in XML ------------------- From 1dc39137bafa3c9da06abd9f7ca23af00dfd1dc8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 23 Feb 2017 17:13:57 +0100 Subject: [PATCH 3/3] Fixed the RST syntax --- service_container/parameters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service_container/parameters.rst b/service_container/parameters.rst index 77d77240dca..d8a01d728f6 100644 --- a/service_container/parameters.rst +++ b/service_container/parameters.rst @@ -253,7 +253,7 @@ key and define the type as ``constant``. YAML files can refer to PHP constants via the ``@=constant('CONSTANT_NAME')`` syntax, which is provided by the - :doc:`Expression Language component /components/expression_language`. See + :doc:`Expression Language component `. See :doc:`/components/expression_language/syntax` to learn more about its syntax. .. tip::