Skip to content

Commit

Permalink
[Config] Fix enum default value in Yaml dumper
Browse files Browse the repository at this point in the history
  • Loading branch information
romainneutron committed Sep 21, 2015
1 parent 0ad587a commit d135d82
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
Expand Up @@ -88,7 +88,7 @@ private function writeNode(NodeInterface $node, $depth = 0)
}
} elseif ($node instanceof EnumNode) {
$comments[] = 'One of '.implode('; ', array_map('json_encode', $node->getValues()));
$default = '~';
$default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~';
} else {
$default = '~';

Expand Down
Expand Up @@ -37,6 +37,7 @@ private function getConfigurationAsString()
return str_replace("\n", PHP_EOL, <<<EOL
<!-- Namespace: http://example.org/schema/dic/acme_root -->
<!-- scalar-required: Required -->
<!-- enum-with-default: One of "this"; "that" -->
<!-- enum: One of "this"; "that" -->
<config
boolean="true"
Expand All @@ -48,6 +49,7 @@ private function getConfigurationAsString()
scalar-array-empty=""
scalar-array-defaults="elem1,elem2"
scalar-required=""
enum-with-default="this"
enum=""
>
Expand Down
Expand Up @@ -43,6 +43,7 @@ private function getConfigurationAsString()
- elem1
- elem2
scalar_required: ~ # Required
enum_with_default: this # One of "this"; "that"
enum: ~ # One of "this"; "that"
# some info
Expand Down
Expand Up @@ -34,6 +34,7 @@ public function getConfigTreeBuilder()
->scalarNode('scalar_array_empty')->defaultValue(array())->end()
->scalarNode('scalar_array_defaults')->defaultValue(array('elem1', 'elem2'))->end()
->scalarNode('scalar_required')->isRequired()->end()
->enumNode('enum_with_default')->values(array('this', 'that'))->defaultValue('this')->end()
->enumNode('enum')->values(array('this', 'that'))->end()
->arrayNode('array')
->info('some info')
Expand Down

0 comments on commit d135d82

Please sign in to comment.