Skip to content

Add documentation for 'useDefaultsIfNotSet()' configuration method #2219

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

Closed
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
14 changes: 13 additions & 1 deletion components/config/definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,12 @@ Array node options
Before defining the children of an array node, you can provide options like:

``useAttributeAsKey()``
Provide the name of a child node, whose value should be used as the key in the resulting array
Provide the name of a child node, whose value should be used as the key in the resulting array.
``requiresAtLeastOneElement()``
There should be at least one element in the array (works only when ``isRequired()`` is also
called).
``addDefaultsIfNotSet()``
If any child nodes have default values, use them if explicit values haven't been provided.

An example of this::

Expand All @@ -198,6 +200,16 @@ An example of this::
->end()
->end()
->end()
->arrayNode('settings')
->useDefaultsIfNotSet()
->children()
->scalarNode('name')
->isRequired()
->cannotBeEmpty()
->defaultValue('value')
->end()
->end()
->end()
->end()
;

Expand Down