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); } }
protected function walk(\SimpleXMLElement $node, \PortlandLabs\Concrete5\MigrationTool\Entity\Import\Tree $tree, TreeNode $parent = null) { foreach ($node->children() as $child) { $n = new TreeNode(); $n->setType((string) $child->getName()); $n->setTitle((string) $child['name']); $n->setTree($tree); $n->setParent($parent); if ($child->count() > 0) { $this->walk($child, $tree, $n); } $tree->getNodes()->add($n); } }