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:
Fabien Potencier 2015-09-01 13:35:06 +02:00
commit 8fbab1e6ad
5 changed files with 16 additions and 7 deletions

View File

@ -84,14 +84,18 @@ class XmlReferenceDumper
// render prototyped nodes
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()) {
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
}
$prototype = $node->getPrototype();
if ($prototype instanceof ArrayNode) {
$children = $prototype->getChildren();
} else {

View File

@ -69,7 +69,12 @@ class YamlReferenceDumper
if ($key = $node->getKeyAttribute()) {
$keyNodeClass = 'Symfony\Component\Config\Definition\\'.($prototype instanceof ArrayNode ? 'ArrayNode' : 'ScalarNode');
$keyNode = new $keyNodeClass($key, $node);
$keyNode->setInfo('Prototype');
$info = 'Prototype';
if (null !== $prototype->getInfo()) {
$info .= ': '.$prototype->getInfo();
}
$keyNode->setInfo($info);
// add children
foreach ($children as $childNode) {

View File

@ -64,7 +64,7 @@ class XmlReferenceDumperTest extends \PHPUnit_Framework_TestCase
child3=""
/>
<!-- prototype -->
<!-- prototype: Parameter name -->
<parameter name="parameter name">scalar value</parameter>
<!-- prototype -->

View File

@ -56,7 +56,7 @@ acme_root:
child3: ~ # Example: example setting
parameters:
# Prototype
# Prototype: Parameter name
name: ~
connections:
# Prototype

View File

@ -53,7 +53,7 @@ class ExampleConfiguration implements ConfigurationInterface
->end()
->arrayNode('parameters')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->prototype('scalar')->info('Parameter name')->end()
->end()
->arrayNode('connections')
->prototype('array')