Skip to content

Commit 1ac90eb

Browse files
committed
Merge pull request #1788 from schmittjoh/patch-1
added some doc about optional sections
2 parents b8512f7 + 2524356 commit 1ac90eb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

components/config/definition.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,29 @@ has a certain value:
212212
->end()
213213
;
214214
215+
Optional Sections
216+
-----------------
217+
If you have entire sections which are optional and can be enabled/disabled,
218+
you can take advantage of the shortcut ``canBeEnabled``, or ``canBeDisabled``::
219+
220+
$arrayNode
221+
->canBeEnabled()
222+
;
223+
224+
// is equivalent to
225+
226+
$arrayNode
227+
->treatFalseLike(array('enabled' => false))
228+
->treatTrueLike(array('enabled' => true))
229+
->treatNullLike(array('enabled' => true))
230+
->children()
231+
->booleanNode('enabled')
232+
->defaultFalse()
233+
;
234+
235+
``canBeDisabled`` looks about the same with the difference that the section
236+
would be enabled by default.
237+
215238
Merging options
216239
---------------
217240

0 commit comments

Comments
 (0)