+
+ /**
+ * @param PrototypedArrayNode $node
+ *
+ * @return array
+ */
+ private function getPrototypeChildren(PrototypedArrayNode $node)
+ {
+ $prototype = $node->getPrototype();
+ $key = $node->getKeyAttribute();
+
+ // Do not expand prototype if it isn't an array node nor uses attribute as key
+ if (!$key && !$prototype instanceof ArrayNode) {
+ return $node->getChildren();
+ }
+
+ if ($prototype instanceof ArrayNode) {
+ $keyNode = new ArrayNode($key, $node);
+ $children = $prototype->getChildren();
+
+ if ($prototype instanceof PrototypedArrayNode && $prototype->getKeyAttribute()) {
+ $children = $this->getPrototypeChildren($prototype);
+ }
+
+ // add children
+ foreach ($children as $childNode) {
+ $keyNode->addChild($childNode);
+ }
+ } else {
+ $keyNode = new ScalarNode($key, $node);
+ }
+
+ $info = 'Prototype';
+ if (null !== $prototype->getInfo()) {
+ $info .= ': '.$prototype->getInfo();
+ }
+ $keyNode->setInfo($info);
+
+ return array($key => $keyNode);
+ }