/**
  * Presun na konkretni pozici
  * @param int $id
  * @param int $parentId
  */
 public function moveTo($id, $parentId)
 {
     $finder = new NodeFinder($this->getTree());
     $item = $finder->findCurrent($id);
     if (!$this->getTree()->isParent($id, $parentId) && $this->shouldMoveTo($item['parentId'], $parentId)) {
         $this->setParent($id, $parentId);
     }
 }
 /**
  * Presun na nizsi pozici
  * @param int $id
  */
 public function down($id)
 {
     $finder = new NodeFinder($this->getTree());
     $current = $finder->findCurrent($id);
     $next = $finder->findNext($id);
     if ($next) {
         $this->swapDirection($next, $current);
     } else {
         $first = $finder->findFirst($id);
         $this->verticalTreeModelAdapter->setPriority($current['id'], $first['priority'] - 1);
     }
 }
 /**
  * @param int $id
  * @return int
  */
 protected function getMaxPriority($id)
 {
     if ($id) {
         $finder = new NodeFinder($this->getTree());
         $item = $finder->findCurrent($id);
         $array = $item['children'];
     } else {
         $array = $this->getTree()->getTree();
     }
     $count = count($array);
     if (!$count) {
         return 0;
     }
     return $array[$count - 1]['priority'];
 }