private function addChildren(ezcTreeNode $node, array $children) { foreach ($children as $name => $child) { if (is_array($child)) { $newNode = $node->tree->createNode($name, $name); $node->addChild($newNode); $this->addChildren($newNode, $child); } else { $newNode = $node->tree->createNode($child, $child); $node->addChild($newNode); } } }
/** * Copies all the children of node $fromNode to node $toNode recursively. * * This method copies all children recursively from $fromNode to $toNode. * The $fromNode belongs to the $from tree and the $toNode to the $to tree. * Data associated with the nodes is copied as well from the store * associated with the $from tree to the $to tree. * * @param ezcTree $from * @param ezcTree $to * @param ezcTreeNode $fromNode * @param ezcTreeNode $toNode */ private static function copyChildren(ezcTree $from, ezcTree $to, ezcTreeNode $fromNode, ezcTreeNode $toNode) { $children = $fromNode->fetchChildren(); foreach (new ezcTreeNodeListIterator($from, $children, true) as $childNodeKey => $childNodeData) { $fromChildNode = $from->fetchNodeById($childNodeKey); $toChildNode = new ezcTreeNode($to, $childNodeKey, $childNodeData); $toNode->addChild($toChildNode); self::copyChildren($from, $to, $fromChildNode, $toChildNode); } }