如果设置了另一个,则如何使Symfony2配置设置成为必需设置?

时间:2013-09-05 14:24:23

标签: symfony

给定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

1 个答案:

答案 0 :(得分:1)

我认为Optional Sections就是你要找的。例如,您可以看到FrameworkBundle profiler的配置。

$rootNode
    ->children()
        ->arrayNode('errorReportAdresses')
            ->canBeEnabled() 
            ->info('a list of commaseparated email addresses')
            ->prototype('scalar')->end()
        ->end()
    ->end()
;