私の構成ノードはと値sourceの両方をサポートできますか?stringarray
からの調達string:
# Valid configuration 1
my_bundle:
source: %kernel.root_dir%/../Resources/config/source.json
からの調達array:
# Valid configuration 2
my_bundle:
source:
operations: []
commands: []
拡張クラスはそれらを区別できます。
if (is_array($config['source']) {
// Bootstrap from array
} else {
// Bootstrap from file
}
私は次のようなものを使うかもしれません:
$rootNode->children()
->variableNode('source')
->validate()
->ifTrue(function ($v) { return !is_string($v) && !is_array($v); })
->thenInvalid('Configuration value must be either string or array.')
->end()
->end()
->end();
sourceしかし、 (操作、コマンドなど) の構造に対する制約を変数ノードに追加するにはどうすればよいでしょうか (その値が type の場合にのみ適用する必要がありますarray)。