Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8fbab1e

Browse files
committed
feature #15635 [Config] Prototypes info (ogizanagi)
This PR was merged into the 2.8 branch. Discussion ---------- [Config] Prototypes info | Q | A | ------------- | --- | Bug fix? | no ? | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Prototypes info is currently ignored by dumpers. It might be useful to add extra informations to the `# Prototype` comment in the `config:dump-reference` output. Commits ------- 599fcb4 [Config] Prototypes info
2 parents 922a534 + 599fcb4 commit 8fbab1e

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,18 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name
8484

8585
// render prototyped nodes
8686
if ($node instanceof PrototypedArrayNode) {
87-
array_unshift($rootComments, 'prototype');
87+
$prototype = $node->getPrototype();
88+
89+
$info = 'prototype';
90+
if (null !== $prototype->getInfo()) {
91+
$info .= ': '.$prototype->getInfo();
92+
}
93+
array_unshift($rootComments, $info);
8894

8995
if ($key = $node->getKeyAttribute()) {
9096
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
9197
}
9298

93-
$prototype = $node->getPrototype();
94-
9599
if ($prototype instanceof ArrayNode) {
96100
$children = $prototype->getChildren();
97101
} else {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ private function writeNode(NodeInterface $node, $depth = 0)
6969
if ($key = $node->getKeyAttribute()) {
7070
$keyNodeClass = 'Symfony\Component\Config\Definition\\'.($prototype instanceof ArrayNode ? 'ArrayNode' : 'ScalarNode');
7171
$keyNode = new $keyNodeClass($key, $node);
72-
$keyNode->setInfo('Prototype');
72+
73+
$info = 'Prototype';
74+
if (null !== $prototype->getInfo()) {
75+
$info .= ': '.$prototype->getInfo();
76+
}
77+
$keyNode->setInfo($info);
7378

7479
// add children
7580
foreach ($children as $childNode) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ enum=""
6464
child3=""
6565
/>
6666
67-
<!-- prototype -->
67+
<!-- prototype: Parameter name -->
6868
<parameter name="parameter name">scalar value</parameter>
6969
7070
<!-- prototype -->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ enum: ~ # One of "this"; "that"
5656
child3: ~ # Example: example setting
5757
parameters:
5858
59-
# Prototype
59+
# Prototype: Parameter name
6060
name: ~
6161
connections:
6262
# Prototype

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function getConfigTreeBuilder()
5353
->end()
5454
->arrayNode('parameters')
5555
->useAttributeAsKey('name')
56-
->prototype('scalar')->end()
56+
->prototype('scalar')->info('Parameter name')->end()
5757
->end()
5858
->arrayNode('connections')
5959
->prototype('array')

0 commit comments

Comments
 (0)