symfony2 semantic bundle configuration - conditional required parameter
I am working on a bundle that have a couple of required parameters. I want
to be able to disable the bundle by setting enabled: false in my
parameters.yml. If the bundle is disabled the configuration parameters
cant be required any more.
Is there anyway I can say in bundle configuration class that the required
parameters are only required if the enabled parameter is true?
Thank you.
EDIT:
My Configuration.php
$rootNode
->children()
->arrayNode('settings')
->canBeEnabled()
->children()
->scalarNode('api_key')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('api_secret')
->isRequired()
->cannotBeEmpty()
->end()
->booleanNode('debug')
->defaultFalse()
->cannotBeEmpty()
->end()
->booleanNode('ssl')
->defaultFalse()
->end()
->end()
->end();
If i set this in parameters.yml,
my_bundle:
settings:
enabled: false
It shouldnt complain about "The child node "api_key" at path
"my_bundle.settings" must be configured."
No comments:
Post a Comment