@@ -189,6 +189,9 @@ reusable configuration value. By convention, parameters are defined under the
189
189
app.some_constant : !php/const GLOBAL_CONSTANT
190
190
app.another_constant : !php/const App\Entity\BlogPost::MAX_ITEMS
191
191
192
+ # Enum case as parameter values
193
+ app.some_enum : !php/enum App\Enum\PostState::Published
194
+
192
195
# ...
193
196
194
197
.. code-block :: xml
@@ -226,6 +229,9 @@ reusable configuration value. By convention, parameters are defined under the
226
229
<!-- PHP constants as parameter values -->
227
230
<parameter key =" app.some_constant" type =" constant" >GLOBAL_CONSTANT</parameter >
228
231
<parameter key =" app.another_constant" type =" constant" >App\Entity\BlogPost::MAX_ITEMS</parameter >
232
+
233
+ <!-- Enum case as parameter values -->
234
+ <parameter key =" app.some_enum" type =" enum" >App\Enum\PostState::Published</parameter >
229
235
</parameters >
230
236
231
237
<!-- ... -->
@@ -237,6 +243,7 @@ reusable configuration value. By convention, parameters are defined under the
237
243
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
238
244
239
245
use App\Entity\BlogPost;
246
+ use App\Enum\PostState;
240
247
241
248
return static function (ContainerConfigurator $containerConfigurator) {
242
249
$containerConfigurator->parameters()
@@ -256,6 +263,9 @@ reusable configuration value. By convention, parameters are defined under the
256
263
// PHP constants as parameter values
257
264
->set('app.some_constant', GLOBAL_CONSTANT)
258
265
->set('app.another_constant', BlogPost::MAX_ITEMS);
266
+
267
+ // Enum case as parameter values
268
+ ->set('app.some_enum', PostState::Published);
259
269
};
260
270
261
271
// ...
@@ -272,6 +282,10 @@ reusable configuration value. By convention, parameters are defined under the
272
282
273
283
</parameter >
274
284
285
+ .. versionadded :: 6.2
286
+
287
+ Passing an enum case as a service parameter was introduced in Symfony 6.2.
288
+
275
289
Once defined, you can reference this parameter value from any other
276
290
configuration file using a special syntax: wrap the parameter name in two ``% ``
277
291
(e.g. ``%app.admin_email% ``):
0 commit comments