protected function addChildNode(\stdClass $parent, TreeNode $n) { $node = new \stdClass(); $node->title = $n->getTitle(); foreach ($n->getChildren() as $child) { $this->addChildNode($node, $child); } $parent->children[] = $node; }
protected function add(TreeNode $node, Node $parent) { $type = NodeType::getByHandle($node->getType()); $class = $type->getTreeNodeTypeClass(); $new = call_user_func_array(array($class, 'add'), array($node->getTitle(), $parent)); foreach ($node->getChildren() as $child) { $this->add($child, $new); } }