@@ -378,6 +378,59 @@ Symfony provides the following env var processors:
378
378
$container->setParameter('env(TRUSTED_HOSTS)', '10.0.0.1,10.0.0.2');
379
379
$framework->trustedHosts(env('TRUSTED_HOSTS')->csv());
380
380
};
381
+ ``env(shuffle:FOO) ``
382
+ Randomly shuffles values of ``FOO ``, which is an array.
383
+ Usable when combining with other processors, as array is a prerequisite.
384
+
385
+ .. configuration-block ::
386
+
387
+ .. code-block :: yaml
388
+
389
+ # config/packages/framework.yaml
390
+ parameters :
391
+ env(REDIS_NODES) : " 127.0.0.1:6380,127.0.0.1:6381"
392
+ services :
393
+ RedisCluster :
394
+ class : RedisCluster
395
+ arguments : [null, "%env(shuffle:csv:REDIS_NODES)%"]
396
+
397
+ .. code-block :: xml
398
+
399
+ <!-- config/packages/framework.xml -->
400
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
401
+ <container xmlns =" http://symfony.com/schema/dic/services"
402
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
403
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
404
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
405
+ https://symfony.com/schema/dic/services/services-1.0.xsd
406
+ http://symfony.com/schema/dic/symfony
407
+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
408
+
409
+ <parameters >
410
+ <parameter key =" env(REDIS_NODES)" >redis://127.0.0.1:6380,redis://127.0.0.1:6381</parameter >
411
+ </parameters >
412
+
413
+ <services >
414
+ <service id =" RedisCluster" class =" RedisCluster" >
415
+ <argument >null</argument >
416
+ <argument >%env(shuffle:csv:REDIS_NODES)%</argument >
417
+ </service >
418
+ </services >
419
+ </container >
420
+
421
+ .. code-block :: php
422
+
423
+ // config/services.php
424
+ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
425
+
426
+ return static function (ContainerConfigurator $configurator): void {
427
+ $container = $configurator->services()
428
+ ->set(\RedisCluster::class, \RedisCluster::class)->args([null, '%env(shuffle:csv:REDIS_NODES)%']);
429
+ };
430
+
431
+ .. versionadded :: 6.2
432
+
433
+ The ``env(shuffle:...) `` env var processor was introduced in Symfony 6.2.
381
434
382
435
``env(file:FOO) ``
383
436
Returns the contents of a file whose path is the value of the ``FOO `` env var:
0 commit comments