Skip to content

Commit c1a7b45

Browse files
committed
minor #7520 [DependencyInjection][Improve] Constant YAML with expression language] (20uf, javiereguiluz)
This PR was merged into the 2.7 branch. Discussion ---------- [DependencyInjection][Improve] Constant YAML with expression language] Hi, Continuation of the PR #7395 for the 2.7 branch. Regards, Commits ------- 1dc3913 Fixed the RST syntax 6d0de9d Minor rewords 79191bf [DependencyInjection][Improve] Constant YAML with expression language]
2 parents 52072d1 + 1dc3913 commit c1a7b45

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

service_container/parameters.rst

Lines changed: 17 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,13 @@ 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+
YAML files can refer to PHP constants via the ``@=constant('CONSTANT_NAME')``
255+
syntax, which is provided by the
256+
:doc:`Expression Language component </components/expression_language>`. See
257+
:doc:`/components/expression_language/syntax` to learn more about its syntax.
258+
246259
.. tip::
247260

248261
If you're using YAML, you can :doc:`import an XML file </service_container/import>`
@@ -253,6 +266,10 @@ key and define the type as ``constant``.
253266
imports:
254267
- { resource: parameters.xml }
255268
269+
.. note::
270+
271+
  In Symfony 3.2, YAML supports PHP constants via the ``!php/const:CONSTANT_NAME`` syntax.
272+
256273
PHP Keywords in XML
257274
-------------------
258275

0 commit comments

Comments
 (0)