[Config] Prototypes info

This commit is contained in:
maxime.steinhausser 2015-08-27 18:05:17 +02:00 committed by ogizanagi
parent 6fd4019975
commit 599fcb4868
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')