8000 bug #20341 Fix YamlReferenceDumper unnamed nested prototypes (ogizanagi) · symfony/symfony@46a8ede · GitHub
[go: up one dir, main page]

Skip to content

Commit 46a8ede

Browse files
committed
bug #20341 Fix YamlReferenceDumper unnamed nested prototypes (ogizanagi)
This PR was squashed before being merged into the 3.2-dev branch (closes #20341). Discussion ---------- Fix YamlReferenceDumper unnamed nested prototypes | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20340 | License | MIT | Doc PR | N/A Ideally, I'd like to output something like: ```yml pipou: # Prototype name: # Prototype - didou: ~ ``` But for now, this should fix the regression. Commits ------- 8e04643 Fix YamlReferenceDumper unnamed nested prototypes
2 parents 700c04b + 8e04643 commit 46a8ede

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private function getPrototypeChildren(PrototypedArrayNode $node)
201201
$keyNode = new ArrayNode($key, $node);
202202
$children = $prototype->getChildren();
203203

204-
if ($prototype instanceof PrototypedArrayNode) {
204+
if ($prototype instanceof PrototypedArrayNode && $prototype->getKeyAttribute()) {
205205
$children = $this->getPrototypeChildren($prototype);
206206
}
207207

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ enum=""
9292
9393
</cms-page>
9494
95+
<!-- prototype -->
96+
<pipou name="pipou name">
97+
98+
<!-- prototype -->
99+
<name didou="" />
100+
101+
</pipou>
102+
95103
</config>
96104
97105
EOL

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ enum: ~ # One of "this"; "that"
7474
locale:
7575
title: ~ # Required
7676
path: ~ # Required
77+
pipou:
78+
79+
# Prototype
80+
name: []
7781

7882
EOL;
7983
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ public function getConfigTreeBuilder()
8080
->end()
8181
->end()
8282
->end()
83+
->arrayNode('pipou')
84+
->useAttributeAsKey('name')
85+
->prototype('array')
86+
->prototype('array')
87+
->children()
88+
->scalarNode('didou')
89+
->end()
90+
->end()
91+
->end()
92+
->end()
93+
->end()
8394
->end()
8495
;
8596

0 commit comments

Comments
 (0)
0