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
This commit is contained in:
commit
8fbab1e6ad
@ -84,14 +84,18 @@ class XmlReferenceDumper
|
|||||||
|
|
||||||
// render prototyped nodes
|
// render prototyped nodes
|
||||||
if ($node instanceof PrototypedArrayNode) {
|
if ($node instanceof PrototypedArrayNode) {
|
||||||
array_unshift($rootComments, 'prototype');
|
$prototype = $node->getPrototype();
|
||||||
|
|
||||||
|
$info = 'prototype';
|
||||||
|
if (null !== $prototype->getInfo()) {
|
||||||
|
$info .= ': '.$prototype->getInfo();
|
||||||
|
}
|
||||||
|
array_unshift($rootComments, $info);
|
||||||
|
|
||||||
if ($key = $node->getKeyAttribute()) {
|
if ($key = $node->getKeyAttribute()) {
|
||||||
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
|
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
$prototype = $node->getPrototype();
|
|
||||||
|
|
||||||
if ($prototype instanceof ArrayNode) {
|
if ($prototype instanceof ArrayNode) {
|
||||||
$children = $prototype->getChildren();
|
$children = $prototype->getChildren();
|
||||||
} else {
|
} else {
|
||||||
|
@ -69,7 +69,12 @@ class YamlReferenceDumper
|
|||||||
if ($key = $node->getKeyAttribute()) {
|
if ($key = $node->getKeyAttribute()) {
|
||||||
$keyNodeClass = 'Symfony\Component\Config\Definition\\'.($prototype instanceof ArrayNode ? 'ArrayNode' : 'ScalarNode');
|
$keyNodeClass = 'Symfony\Component\Config\Definition\\'.($prototype instanceof ArrayNode ? 'ArrayNode' : 'ScalarNode');
|
||||||
$keyNode = new $keyNodeClass($key, $node);
|
$keyNode = new $keyNodeClass($key, $node);
|
||||||
$keyNode->setInfo('Prototype');
|
|
||||||
|
$info = 'Prototype';
|
||||||
|
if (null !== $prototype->getInfo()) {
|
||||||
|
$info .= ': '.$prototype->getInfo();
|
||||||
|
}
|
||||||
|
$keyNode->setInfo($info);
|
||||||
|
|
||||||
// add children
|
// add children
|
||||||
foreach ($children as $childNode) {
|
foreach ($children as $childNode) {
|
||||||
|
@ -64,7 +64,7 @@ class XmlReferenceDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
child3=""
|
child3=""
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- prototype -->
|
<!-- prototype: Parameter name -->
|
||||||
<parameter name="parameter name">scalar value</parameter>
|
<parameter name="parameter name">scalar value</parameter>
|
||||||
|
|
||||||
<!-- prototype -->
|
<!-- prototype -->
|
||||||
|
@ -56,7 +56,7 @@ acme_root:
|
|||||||
child3: ~ # Example: example setting
|
child3: ~ # Example: example setting
|
||||||
parameters:
|
parameters:
|
||||||
|
|
||||||
# Prototype
|
# Prototype: Parameter name
|
||||||
name: ~
|
name: ~
|
||||||
connections:
|
connections:
|
||||||
# Prototype
|
# Prototype
|
||||||
|
@ -53,7 +53,7 @@ class ExampleConfiguration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->arrayNode('parameters')
|
->arrayNode('parameters')
|
||||||
->useAttributeAsKey('name')
|
->useAttributeAsKey('name')
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->info('Parameter name')->end()
|
||||||
->end()
|
->end()
|
||||||
->arrayNode('connections')
|
->arrayNode('connections')
|
||||||
->prototype('array')
|
->prototype('array')
|
||||||
|
Reference in New Issue
Block a user