From 36d0902b569ca84cdb445602d78621cac465a935 Mon Sep 17 00:00:00 2001 From: Michael COULLERET Date: Sat, 21 Jan 2017 12:44:44 +0100 Subject: [PATCH 1/2] YAML with expression language Add example constant YAML with expression language --- service_container/parameters.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/service_container/parameters.rst b/service_container/parameters.rst index 0c1890e3dfd..921d8cff77a 100644 --- a/service_container/parameters.rst +++ b/service_container/parameters.rst @@ -253,6 +253,15 @@ key and define the type as ``constant``. imports: - { resource: parameters.xml } +It's also possible to use PHP constants in YAML files using expression language. +To learn more about the expression language syntax, see :doc:`/components/expression_language/syntax`. + +.. code-block:: yaml + + parameters: + global.constant.value: "@=constant('GLOBAL_CONSTANT')" + my_class.constant.value: "@=constant('My_Class::CONSTANT_NAME')" + PHP Keywords in XML ------------------- From a4d11b96d77e990439aa149be2667e91e23b1515 Mon Sep 17 00:00:00 2001 From: Michael COULLERET Date: Wed, 22 Feb 2017 15:11:06 +0100 Subject: [PATCH 2/2] [#7395] Improve example for 2.7 & 2.8 --- service_container/parameters.rst | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/service_container/parameters.rst b/service_container/parameters.rst index 921d8cff77a..fd4024869eb 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,14 +265,10 @@ key and define the type as ``constant``. imports: - { resource: parameters.xml } -It's also possible to use PHP constants in YAML files using expression language. -To learn more about the expression language syntax, see :doc:`/components/expression_language/syntax`. +.. note:: -.. code-block:: yaml + In Symfony 3.2 YAML support PHP constants. - parameters: - global.constant.value: "@=constant('GLOBAL_CONSTANT')" - my_class.constant.value: "@=constant('My_Class::CONSTANT_NAME')" PHP Keywords in XML -------------------