8000 [Config] Allow using an enum FQCN with `EnumNode` by alexandre-daubois · Pull Request #20694 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Config] Allow using an enum FQCN with EnumNode #20694

8000 New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Config] Allow using an enum FQCN with EnumNode
  • Loading branch information
alexandre-daubois committed Feb 26, 2025
commit a2daec4d72e47b9ce07e0bc915834f3594b7f453
19 changes: 19 additions & 0 deletions components/config/definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,25 @@ The configuration can now be written like this::
->end()
;

You can also use the ``enumClass()`` method to pass the FQCN of an enum
class to the node. This will automatically set the values of the node to
the cases of the enum::

$rootNode
->children()
->enumNode('delivery')
->enumClass(Delivery::class)
->end()
->end()
;

When using a backed enum, the values provided to the node will be casted
to one of the enum cases if possible.

.. versionadded:: 7.3

The ``enumClass()`` method was introduced in Symfony 7.3.

Array Nodes
~~~~~~~~~~~

Expand Down
0