File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -745,11 +745,13 @@ Symfony provides the following env var processors:
745
745
Tries to convert an environment variable to an actual ``\BackedEnum `` value.
746
746
This processor takes the fully qualified name of the ``\BackedEnum `` as an argument::
747
747
748
- # App\Enum\Environment
748
+ // App\Enum\Suit.php
749
749
enum Environment: string
750
750
{
751
- case Development = 'dev';
752
- case Production = 'prod';
751
+ case Clubs = 'clubs';
752
+ case Spades = 'spades';
753
+ case Diamonds = 'diamonds';
754
+ case Hearts = 'hearts';
753
755
}
754
756
755
757
.. configuration-block ::
@@ -758,7 +760,7 @@ Symfony provides the following env var processors:
758
760
759
761
# config/services.yaml
760
762
parameters :
761
- typed_env : ' %env(enum:App\Enum\Environment:APP_ENV )%'
763
+ suit : ' %env(enum:App\Enum\Suit:CARD_SUIT )%'
762
764
763
765
.. code-block :: xml
764
766
@@ -773,14 +775,17 @@ Symfony provides the following env var processors:
773
775
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
774
776
775
777
<parameters >
776
- <parameter key =" typed_env " >%env(enum:App\Enum\Environment:APP_ENV )%</parameter >
778
+ <parameter key =" suit " >%env(enum:App\Enum\Suit:CARD_SUIT )%</parameter >
777
779
</parameters >
778
780
</container >
779
781
780
782
.. code-block :: php
781
783
782
784
// config/services.php
783
- $container->setParameter('typed_env', '%env(enum:App\Enum\Environment:APP_ENV)%');
785
+ $container->setParameter('suit', '%env(enum:App\Enum\Suit:CARD_SUIT)%');
786
+
787
+ The value stored in the ``CARD_SUIT `` env var would be a string (e.g. ``'spades' ``)
788
+ but the application will use the enum value (e.g. ``Suit::Spades ``).
784
789
785
790
.. versionadded :: 6.2
786
791
You can’t perform that action at this time.
0 commit comments