8000 [Config] Fix (Yaml|Xml)ReferenceDumper for nested prototypes by ogizanagi · Pull Request #19480 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Config] Fix (Yaml|Xml)ReferenceDumper for nested prototypes #19480

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 16, 2016
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 @@ -96,7 +96,10 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name
$rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
}

if ($prototype instanceof ArrayNode) {
if ($prototype instanceof PrototypedArrayNode) {
$prototype->setName($key);
$children = array($key => $prototype);
} elseif ($prototype instanceof ArrayNode) {
$children = $prototype->getChildren();
} else {
if ($prototype->hasDefaultValue()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,14 @@ private function getPrototypeChildren(PrototypedArrayNode $node)

if ($prototype instanceof ArrayNode) {
$keyNode = new ArrayNode($key, $node);
$children = $prototype->getChildren();

if ($prototype instanceof PrototypedArrayNode) {
$children = $this->getPrototypeChildren($prototype);
}

// add children
foreach ($prototype->getChildren() as $childNode) {
foreach ($children as $childNode) {
$keyNode->addChild($childNode);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ enum=""
pass=""
/>

<!-- prototype -->
<cms-page page="cms page page">

<!-- prototype -->
<!-- title: Required -->
<!-- path: Required -->
<page
locale="page locale"
title=""
path=""
/>

</cms-page>

</config>

EOL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ enum: ~ # One of "this"; "that"
-
user: ~
pass: ~
cms_pages:

# Prototype
page:

# Prototype
locale:
title: ~ # Required
path: ~ # Required

EOL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function getConfigTreeBuilder()
$rootNode
->fixXmlConfig('parameter')
->fixXmlConfig('connection')
->fixXmlConfig('cms_page')
->children()
->booleanNode('boolean')->defaultTrue()->end()
->scalarNode('scalar_empty')->end()
Expand Down Expand Up @@ -67,6 +68,18 @@ public function getConfigTreeBuilder()
->end()
->end()
->end()
->arrayNode('cms_pages')
->useAttributeAsKey('page')
->prototype('array')
->useAttributeAsKey('locale')
->prototype('array')
->children()
->scalarNode('title')->isRequired()->end()
->scalarNode('path')->isRequired()->end()
->end()
->end()
->end()
->end()
->end()
;

Expand Down
0