構成クラスを使用して、数値キーなしで配列ノードを定義するにはどうすればよいですか?配列の子は、それ以上の構成オプションを表しません。むしろ、それらは全体としてのみ、選択的に上書きすることができないリストになります。
これまでのところ:
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder;
$root = $treeBuilder->root('acme_base');
$root
->children()
->arrayNode('entities')
// Unfortunately, this doesn't work
->defaultValue(array(
'Acme\BaseBundle\Entity\DefaultEntity1',
'Acme\BaseBundle\Entity\DefaultEntity2',
))
->end()
->end();
return $treeBuilder;
}
でapp/config.yml
、次のように上書きできるようにします。
acme_base:
entities:
- 'Acme\BaseBundle\Entity\AnotherEntity1'
- 'Acme\BaseBundle\Entity\AnotherEntity2'
- 'Acme\BaseBundle\Entity\AnotherEntity3'
- 'Acme\BaseBundle\Entity\AnotherEntity4'