TreeBuilder不会改变我的配置

时间:2019-10-03 07:00:45

标签: symfony-3.4

我用SF3.4编写了一个配置加载器。

我想要拥有:

['mapping' => ['request' => 'a', 'response' => 'b']

具有以下配置:

custom:
   mapping:
     request: a
     response: b

我想要:

['mapping' => ['request' => 'a', 'response' => 'a']

与此:

custom:
   mapping: a

我有树生成器

    ->arrayNode('mapping')
                ->beforeNormalization()
                    ->ifString()
                    ->then(function($value) { return ['request' => $value, 'response' => $value]; })
                ->end()
                ->children()
                    ->scalarNode('request')->isRequired()->end()
                    ->scalarNode('response')->isRequired()->end()
                ->end()
            ->end()

有了这个节点配置

['mapping' => ['request' => 'a', 'response' => 'b']

['mapping' => ['a']

代替

['mapping' => ['request' => 'a', 'response' => 'b']

['mapping' => ['request' => 'a', 'response' => 'a']

未调用beforeNormalization吗?如何获得所需的配置?

0 个答案:

没有答案