Symfony Config : how to handle entire section require status ?


Symfony Config Component is an extremely powerful way of configuring bundles and apps. For my work in progress in LCH User bundle, I wanted to set templates array node as not required.

What's at stake

All other nodes types are not required unless you add the isRequired() (example) method to your node. Doing so, you will have an exception thrown saying that you have to define this key, which is what you want.

For the array node, it's different : it's enabled by default and you have to specify the canBeEnabled() (example) method to your array node to ensure that it will be disabled by default, but enabled if needed.

Tags: symfony, config