Skip to content

Commit 79191bf

Browse files
committed
[DependencyInjection][Improve] Constant YAML with expression language]
1 parent 52072d1 commit 79191bf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

service_container/parameters.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ key and define the type as ``constant``.
225225

226226
.. configuration-block::
227227

228+
.. code-block:: yaml
229+
230+
parameters:
231+
global.constant.value: "@=constant('GLOBAL_CONSTANT')"
232+
my_class.constant.value: "@=constant('My_Class::CONSTANT_NAME')"
233+
228234
.. code-block:: xml
229235
230236
<?xml version="1.0" encoding="UTF-8" ?>
@@ -243,6 +249,12 @@ key and define the type as ``constant``.
243249
$container->setParameter('global.constant.value', GLOBAL_CONSTANT);
244250
$container->setParameter('my_class.constant.value', My_Class::CONSTANT_NAME);
245251
252+
.. caution::
253+
254+
It's also possible to use PHP constants in YAML files using expression language.
255+
You must have :doc:`/components/expression_language` installed.
256+
To learn more about the expression language syntax, see :doc:`/components/expression_language/syntax`.
257+
246258
.. tip::
247259

248260
If you're using YAML, you can :doc:`import an XML file </service_container/import>`
@@ -253,6 +265,10 @@ key and define the type as ``constant``.
253265
imports:
254266
- { resource: parameters.xml }
255267
268+
.. note::
269+
270+
In Symfony 3.2 YAML support PHP constants.
271+
256272
PHP Keywords in XML
257273
-------------------
258274

0 commit comments

Comments
 (0)