Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
28 changes: 28 additions & 0 deletions components/config/definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,34 @@ values::
This will restrict the ``delivery`` options to be either ``standard``,
``expedited`` or ``priority``.

You can also provide enum values to ``enumNode()``. Let's define an enumeration
describing the possible states of the example above::

enum Delivery: string
{
case Standard = 'standard';
case Expedited = 'expedited';
case Priority = 'priority';
}

The configuration can now be written like this::

$rootNode
->children()
->enumNode('delivery')
// You can provide all values of the enum...
->values(Delivery::cases())
// ... or you can pass only some values next to other scalar values
->values([Delivery::Priority, Delivery::Standard, 'other', false])
->end()
->end()
;

.. versionadded:: 6.3

The support of enum values in ``enumNode()`` was introduced
in Symfony 6.3.

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

Expand Down