2

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

4

1 回答 1

1

我认为可选部分是您正在寻找的。您可以看到对FrameworkBundle profiler的配置的敌人示例。

$rootNode
    ->children()
        ->arrayNode('errorReportAdresses')
            ->canBeEnabled() 
            ->info('a list of commaseparated email addresses')
            ->prototype('scalar')->end()
        ->end()
    ->end()
;
于 2013-09-05T14:44:58.850 回答