/** * Adds a given category. * @param Category $category The category to add to the tree * @return Category the added category */ public function addCategory(AbstractCategory $category) { $parent = $category->getParent(); if ($parent == 0) { $parent = $this->getRootNode(); } else { $parent = PartKeepr::getEM()->find($this->categoryClass, $parent); $parent = new NodeWrapper($parent, $this->getNodeManager()); } $node = $parent->addChild($category); // Force category path update $this->updateCategoryPaths($node); // Flush the category path changes PartKeepr::getEM()->flush(); return $node; }
/** * Adds a given category. * @param Category $category The category to add to the tree * @return Category the added category */ public function addCategory (Category $category) { $parent = $category->getParent(); if ($parent == 0) { $parent = $this->getRootNode(); } else { $parent = PartKeepr::getEM()->find("de\RaumZeitLabor\PartKeepr\Category\Category", $parent); $parent = new NodeWrapper($parent, $this->getNodeManager()); } return $parent->addChild($category); }