public function create($params) { $model = new $this->model(); $nsm = new Manager(new Config($this->entityManager, $this->model)); foreach ($params as $k => $v) { $f = 'set' . ucfirst($k); if (method_exists($model, $f)) { $model->{$f}($v); } } if ($model->getParentId() > 0) { // add new post as a child of another post $parent = $nsm->fetchTree($model->getParentId()); $parent->addChild($model); return $model; } else { $nsm->createRoot($model); return $model; } }
public function createRootNode(array $values) { $entity = new MenuItem(); $this->updateNode($entity, $values); return $this->nestedSetManager->createRoot($entity); }