Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e80510

Browse filesBrowse files
committed
[Config] Fix YamlReferenceDumper for nested prototypes
1 parent 835176c commit 1e80510
Copy full SHA for 1e80510

File tree

5 files changed

+47
-2
lines changed
Filter options

5 files changed

+47
-2
lines changed

‎src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name
9696
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
9797
}
9898

99-
if ($prototype instanceof ArrayNode) {
99+
if ($prototype instanceof PrototypedArrayNode) {
100+
$prototype->setName($key);
101+
$children = array($key => $prototype);
102+
} elseif ($prototype instanceof ArrayNode) {
100103
$children = $prototype->getChildren();
101104
} else {
102105
if ($prototype->hasDefaultValue()) {

‎src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,14 @@ private function getPrototypeChildren(PrototypedArrayNode $node)
199199

200200
if ($prototype instanceof ArrayNode) {
201201
$keyNode = new ArrayNode($key, $node);
202+
$children = $prototype->getChildren();
203+
204+
if ($prototype instanceof PrototypedArrayNode) {
205+
$children = $this->getPrototypeChildren($prototype);
206+
}
207+
202208
// add children
203-
foreach ($prototype->getChildren() as $childNode) {
209+
foreach ($children as $childNode) {
204210
$keyNode->addChild($childNode);
205211
}
206212
} else {

‎src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,20 @@ enum=""
7878
pass=""
7979
/>
8080
81+
<!-- prototype -->
82+
<cms-page page="cms page page">
83+
84+
<!-- prototype -->
85+
<!-- title: Required -->
86+
<!-- path: Required -->
87+
<page
88+
locale="page locale"
89+
title=""
90+
path=""
91+
/>
92+
93+
</cms-page>
94+
8195
</config>
8296
8397
EOL

‎src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ enum: ~ # One of "this"; "that"
6565
-
6666
user: ~
6767
pass: ~
68+
cms_pages:
69+
70+
# Prototype
71+
page:
72+
73+
# Prototype
74+
locale:
75+
title: ~ # Required
76+
path: ~ # Required
6877

6978
EOL;
7079
}

‎src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function getConfigTreeBuilder()
2424
$rootNode
2525
->fixXmlConfig('parameter')
2626
->fixXmlConfig('connection')
27+
->fixXmlConfig('cms_page')
2728
->children()
2829
->booleanNode('boolean')->defaultTrue()->end()
2930
->scalarNode('scalar_empty')->end()
@@ -67,6 +68,18 @@ public function getConfigTreeBuilder()
6768
->end()
6869
->end()
6970
->end()
71+
->arrayNode('cms_pages')
72+
->useAttributeAsKey('page')
73+
->prototype('array')
74+
->useAttributeAsKey('locale')
75+
->prototype('array')
76+
->children()
77+
->scalarNode('title')->isRequired()->end()
78+
->scalarNode('path')->isRequired()->end()
79+
->end()
80+
->end()
81+
->end()
82+
->end()
7083
->end()
7184
;
7285

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.