给定Symfony2配置:
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('acme');
$rootNode
->children()
->booleanNode('enableErrorReport')
->defaultFalse()
->end()
->arrayNode('errorReportAdresses')
->info('a list of commaseparated email addresses')
->prototype('scalar')->end()
->end()
->end()
;
如果errorReportAdresses
为真,我怎样才能强制enableErrorReport
?
答案 0 :(得分:1)
我认为Optional Sections就是你要找的。例如,您可以看到FrameworkBundle profiler的配置。
$rootNode
->children()
->arrayNode('errorReportAdresses')
->canBeEnabled()
->info('a list of commaseparated email addresses')
->prototype('scalar')->end()
->end()
->end()
;