I'm using Symfony Config Component in Silex framework and I need to have an array of data which holds an array of versions :
some_data:
# some config...
versions:
- 1.1
- 1.2-beta
...
Here's a glimpse at the config tree builder :
$node = $treeBuilder->root('some_data');
$node
->children()
// some nodes...
->arrayNode('versions')
->addDefaultChildrenIfNoneSet()
->validate()
->ifTrue(function ($v) {
return !empty($v);
})
->then(function ($v) {
$array = array_values(array_unique($v));
sort($array, SORT_NATURAL | SORT_FLAG_CASE);
return $array;
})
->end()
->prototype('scalar')->defaultValue('1')->end()
->end()
->end()
->end()
When no versions
are set I got default 1
, alright.
But when I add some other versions and then try to delete default value 1
, it always comes back after processing config.
Does someone understand what I am doing wrong ? Is it an expected behaviour ?