Skip to content

Commit a2daec4

Browse files
[Config] Allow using an enum FQCN with EnumNode
1 parent 15cddbe commit a2daec4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

components/config/definition.rst

+19
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,25 @@ The configuration can now be written like this::
186186
->end()
187187
;
188188

189+
You can also use the ``enumClass()`` method to pass the FQCN of an enum
190+
class to the node. This will automatically set the values of the node to
191+
the cases of the enum::
192+
193+
$rootNode
194+
->children()
195+
->enumNode('delivery')
196+
->enumClass(Delivery::class)
197+
->end()
198+
->end()
199+
;
200+
201+
When using a backed enum, the values provided to the node will be casted
202+
to one of the enum cases if possible.
203+
204+
.. versionadded:: 7.3
205+
206+
The ``enumClass()`` method was introduced in Symfony 7.3.
207+
189208
Array Nodes
190209
~~~~~~~~~~~
191210

0 commit comments

Comments
 (0)