Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Config] Fix YamlReferenceDumper prototyped array support #19569

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

Closed
wants to merge 1 commit into from
Closed
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
[Config] Fix YamlReferenceDumper prototyped array support
  • Loading branch information
ogizanagi committed Aug 8, 2016
commit ca1352541c8eb5b71b2df5ce3234b6fd18032aaf
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public function dumpNode(NodeInterface $node)
/**
* @param NodeInterface $node
* @param int $depth
* @param bool $prototypedArray
*/
private function writeNode(NodeInterface $node, $depth = 0)
private function writeNode(NodeInterface $node, $depth = 0, $prototypedArray = false)
{
$comments = array();
$default = '';
Expand All @@ -66,17 +67,17 @@ private function writeNode(NodeInterface $node, $depth = 0)
}

// check for attribute as key
if ($key = $node->getKeyAttribute()) {
$keyNodeClass = 'Symfony\Component\Config\Definition\\'.($prototype instanceof ArrayNode ? 'ArrayNode' : 'ScalarNode');
$keyNode = new $keyNodeClass($key, $node);
$keyNode->setInfo('Prototype');

// add children
foreach ($children as $childNode) {
$keyNode->addChild($childNode);
}
$children = array($key => $keyNode);
$key = $node->getKeyAttribute();

$keyNodeClass = 'Symfony\Component\Config\Definition\\'.($prototype instanceof ArrayNode ? 'ArrayNode' : 'ScalarNode');
$keyNode = new $keyNodeClass($key, $node);
$keyNode->setInfo('Prototype');

// add children
foreach ($children as $childNode) {
$keyNode->addChild($childNode);
}
$children = array($key => $keyNode);
}

if (!$children) {
Expand Down Expand Up @@ -120,7 +121,8 @@ private function writeNode(NodeInterface $node, $depth = 0)
$default = (string) $default != '' ? ' '.$default : '';
$comments = count($comments) ? '# '.implode(', ', $comments) : '';

$text = rtrim(sprintf('%-20s %s %s', $node->getName().':', $default, $comments), ' ');
$key = $prototypedArray ? '-' : $node->getName().':';
$text = rtrim(sprintf('%-20s %s %s', $key, $default, $comments), ' ');

if ($info = $node->getInfo()) {
$this->writeLine('');
Expand Down Expand Up @@ -154,7 +156,7 @@ private function writeNode(NodeInterface $node, $depth = 0)

if ($children) {
foreach ($children as $childNode) {
$this->writeNode($childNode, $depth + 1);
$this->writeNode($childNode, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function testDumper()

$dumper = new YamlReferenceDumper();

$this->markTestIncomplete('The Yaml Dumper currently does not support prototyped arrays');
$this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration));
}

Expand All @@ -32,7 +31,7 @@ private function getConfigurationAsString()
acme_root:
boolean: true
scalar_empty: ~
scalar_null: ~
scalar_null: null
scalar_true: true
scalar_false: false
scalar_default: default
Expand Down Expand Up @@ -60,8 +59,11 @@ enum: ~ # One of "this"; "that"
# Prototype
name: ~
connections:

# Prototype
- { user: ~, pass: ~ }
-
user: ~
pass: ~

EOL;
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.