File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -698,6 +698,49 @@ Symfony provides the following env var processors:
698698 ],
699699 ]);
700700
701+ ``env(enum:FooEnum:BAR) ``
702+ Tries to convert an environment variable to an actual ``\BackedEnum `` value. This processor takes the fully qualified
703+ name of the ``\BackedEnum `` as an argument.
704+
705+ .. code-block :: php
706+
707+ # App\Enum\Environment
708+ enum Environment: string
709+ {
710+ case Development = 'dev';
711+ case Production = 'prod';
712+ }
713+
714+ .. configuration-block ::
715+
716+ .. code-block :: yaml
717+
718+ # config/services.yaml
719+ parameters :
720+ typed_env : ' %env(enum:App\Enum\Environment:APP_ENV)%'
721+
722+ .. code-block :: xml
723+
724+ <!-- config/services.xml -->
725+ <?xml version =" 1.0" encoding =" UTF-8" ?>
726+ <container xmlns =" http://symfony.com/schema/dic/services"
727+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
728+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
729+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
730+ https://symfony.com/schema/dic/services/services-1.0.xsd
731+ http://symfony.com/schema/dic/symfony
732+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
733+
734+ <parameters >
735+ <parameter key =" typed_env" >%env(enum:App\Enum\Environment:APP_ENV)%</parameter >
736+ </parameters >
737+ </container >
738+
739+ .. code-block :: php
740+
741+ // config/services.php
742+ $container->setParameter('typed_env', '%env(enum:App\Enum\Environment:APP_ENV)%');
743+
701744 It is also possible to combine any number of processors:
702745
703746.. configuration-block ::
You can’t perform that action at this time.
0 commit comments