[Config] Fix YamlReferenceDumper for nested prototypes
This commit is contained in:
parent
835176c932
commit
1e8051081c
@ -96,7 +96,10 @@ class XmlReferenceDumper
|
|||||||
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
|
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($prototype instanceof ArrayNode) {
|
if ($prototype instanceof PrototypedArrayNode) {
|
||||||
|
$prototype->setName($key);
|
||||||
|
$children = array($key => $prototype);
|
||||||
|
} elseif ($prototype instanceof ArrayNode) {
|
||||||
$children = $prototype->getChildren();
|
$children = $prototype->getChildren();
|
||||||
} else {
|
} else {
|
||||||
if ($prototype->hasDefaultValue()) {
|
if ($prototype->hasDefaultValue()) {
|
||||||
|
@ -199,8 +199,14 @@ class YamlReferenceDumper
|
|||||||
|
|
||||||
if ($prototype instanceof ArrayNode) {
|
if ($prototype instanceof ArrayNode) {
|
||||||
$keyNode = new ArrayNode($key, $node);
|
$keyNode = new ArrayNode($key, $node);
|
||||||
|
$children = $prototype->getChildren();
|
||||||
|
|
||||||
|
if ($prototype instanceof PrototypedArrayNode) {
|
||||||
|
$children = $this->getPrototypeChildren($prototype);
|
||||||
|
}
|
||||||
|
|
||||||
// add children
|
// add children
|
||||||
foreach ($prototype->getChildren() as $childNode) {
|
foreach ($children as $childNode) {
|
||||||
$keyNode->addChild($childNode);
|
$keyNode->addChild($childNode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -78,6 +78,20 @@ class XmlReferenceDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
pass=""
|
pass=""
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- prototype -->
|
||||||
|
<cms-page page="cms page page">
|
||||||
|
|
||||||
|
<!-- prototype -->
|
||||||
|
<!-- title: Required -->
|
||||||
|
<!-- path: Required -->
|
||||||
|
<page
|
||||||
|
locale="page locale"
|
||||||
|
title=""
|
||||||
|
path=""
|
||||||
|
/>
|
||||||
|
|
||||||
|
</cms-page>
|
||||||
|
|
||||||
</config>
|
</config>
|
||||||
|
|
||||||
EOL
|
EOL
|
||||||
|
@ -65,6 +65,15 @@ acme_root:
|
|||||||
-
|
-
|
||||||
user: ~
|
user: ~
|
||||||
pass: ~
|
pass: ~
|
||||||
|
cms_pages:
|
||||||
|
|
||||||
|
# Prototype
|
||||||
|
page:
|
||||||
|
|
||||||
|
# Prototype
|
||||||
|
locale:
|
||||||
|
title: ~ # Required
|
||||||
|
path: ~ # Required
|
||||||
|
|
||||||
EOL;
|
EOL;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ class ExampleConfiguration implements ConfigurationInterface
|
|||||||
$rootNode
|
$rootNode
|
||||||
->fixXmlConfig('parameter')
|
->fixXmlConfig('parameter')
|
||||||
->fixXmlConfig('connection')
|
->fixXmlConfig('connection')
|
||||||
|
->fixXmlConfig('cms_page')
|
||||||
->children()
|
->children()
|
||||||
->booleanNode('boolean')->defaultTrue()->end()
|
->booleanNode('boolean')->defaultTrue()->end()
|
||||||
->scalarNode('scalar_empty')->end()
|
->scalarNode('scalar_empty')->end()
|
||||||
@ -67,6 +68,18 @@ class ExampleConfiguration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
->arrayNode('cms_pages')
|
||||||
|
->useAttributeAsKey('page')
|
||||||
|
->prototype('array')
|
||||||
|
->useAttributeAsKey('locale')
|
||||||
|
->prototype('array')
|
||||||
|
->children()
|
||||||
|
->scalarNode('title')->isRequired()->end()
|
||||||
|
->scalarNode('path')->isRequired()->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
->end()
|
->end()
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user