/**
  * Vytvori pole prvku option ze stromu
  * @param Tree $tree
  * @return array
  */
 public function createOptions(Tree $tree)
 {
     $items = [];
     $arrayTree = $tree->getTree();
     $this->fill($items, $arrayTree);
     return $items;
 }
示例#2
0
 /**
  * @param \Nette\Application\UI\ITemplate $template
  */
 protected function prepareTemplate(ITemplate $template)
 {
     parent::prepareTemplate($template);
     $this->registerHelper($template);
     $template->menu = $this->tree->getTree();
     $template->currentPosition = $this->getCurrentPositionMap();
 }
 /**
  * @param int $currentId
  * @return array
  */
 private function buildMap($currentId)
 {
     $map = $this->tree->getMap();
     $currentMap = [];
     while ($currentId) {
         array_unshift($currentMap, $currentId);
         $currentId = $map[$currentId]['parentId'];
     }
     return $currentMap;
 }
 /**
  * @param int $id
  * @return array
  * @throws \Nette\InvalidStateException
  */
 public function findBranch($id)
 {
     $item = $this->findCurrent($id);
     if ($item['parentId']) {
         return $this->findCurrent($item['parentId'])['children'];
     } else {
         return $this->tree->getTree();
     }
 }
 /**
  * @param Tree $tree
  * @return array
  */
 public function convert(Tree $tree)
 {
     $items = [];
     $this->fillItems($items, $tree->getTree(), 0);
     return $items;
 }