Skip to content

[Config] Prototypes info #15635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name

// 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ private function writeNode(NodeInterface $node, $depth = 0)
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ enum=""
child3=""
/>

<!-- prototype -->
<!-- prototype: Parameter name -->
<parameter name="parameter name">scalar value</parameter>

<!-- prototype -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum: ~ # One of "this"; "that"
child3: ~ # Example: example setting
parameters:

# Prototype
# Prototype: Parameter name
name: ~
connections:
# Prototype
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getConfigTreeBuilder()
->end()
->arrayNode('parameters')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->prototype('scalar')->info('Parameter name')->end()
->end()
->arrayNode('connections')
->prototype('array')
Expand Down