Skip to content

Commit 1a02013

Browse files
committed
minor #17673 [Config] Introducing the new param() function as early as possible (ThomasLandauer)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Config] Introducing the new `param()` function as early as possible Commits ------- a4c1261 [Config] Introducing the new `param()` function as early as possible
2 parents 819361a + a4c1261 commit 1a02013

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

configuration.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,6 @@ configuration file using a special syntax: wrap the parameter name in two ``%``
304304
# any string surrounded by two % is replaced by that parameter value
305305
email_address: '%app.admin_email%'
306306
307-
# ...
308-
309307
.. code-block:: xml
310308
311309
<!-- config/packages/some_package.xml -->
@@ -328,13 +326,17 @@ configuration file using a special syntax: wrap the parameter name in two ``%``
328326
329327
// config/packages/some_package.php
330328
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
329+
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
331330
332331
return static function (ContainerConfigurator $container) {
333332
$container->extension('some_package', [
334-
// any string surrounded by two % is replaced by that parameter value
335-
'email_address' => '%app.admin_email%',
333+
// when using the param() function, you only have to pass the parameter name...
334+
'email_address' => param('app.admin_email'),
336335
337-
// ...
336+
// ... but if you prefer it, you can also pass the name as a string
337+
// surrounded by two % (same as in YAML and XML formats) and Symfony will
338+
// replace it by that parameter value
339+
'email_address' => '%app.admin_email%',
338340
]);
339341
};
340342

0 commit comments

Comments
 (0)