protected function getLastChildPosition(NodeInterface $node, NodeInterface $newParent)
 {
     $method = array($this->_nodeClassName, 'where');
     $pos = call_user_func($method, $this->parentCol(), '=', $newParent->__get($this->pkCol()))->max($this->sortCol());
     if (is_numeric($pos) && $pos) {
         return (int) $pos + 1;
     }
     return 1;
 }
Exemplo n.º 2
0
 public function delete(Node $node, $deleteChildNodes = TRUE)
 {
     if (!$deleteChildNodes) {
         throw new DomainException('Non-recursive delete is not supported right now');
     }
     $subtree = $this->get($node->__get($this->pkCol()), $node->__get($this->rootCol()));
     $byDepth = array();
     foreach (Helper::flatify($subtree) as $deleteNode) {
         if (!isset($byDepth[$deleteNode->getDepth()])) {
             $byDepth[$deleteNode->getDepth()] = array();
         }
         $byDepth[$deleteNode->getDepth()][] = $deleteNode;
     }
     krsort($byDepth, SORT_NUMERIC);
     foreach ($byDepth as $depth => $depthNodes) {
         foreach ($depthNodes as $deleteNode) {
             $deleteNode->delete();
         }
     }
     return $this;
 }