/** * @param int $sectionId * @return \Esports\Utils\Tree */ protected function getTree($sectionId) { $tree = $this->menuTreeFactory->create($sectionId); $tree->onNodeCreated = function ($node, $data) { $node->name = $data->name; }; return $tree; }
/** * @return Tree */ public function create() { $tree = $this->menuTreeFactory->create($this->sectionId); $tree->onNodeCreated[] = function ($item, $data) { $item->priority = $data['priority']; }; return $tree; }
public function validateNonCircular(Form $form) { $parentId = $this->getParentIdFromForm($form); if ($this->menuTreeFactory->create($this->sectionId)->isParent($this->id, $parentId)) { $form['parent']['id_menu']->addError('Detekce cyklické závislosti'); } }
/** * @return array */ protected function createItems() { $tree = $this->menuTreeFactory->create($this->sectionId); $tree->onNodeCreated[] = function ($item, $data) { $item->name = $data['name']; $item->show = $data['show']; $item->type_name = $data['type_name']; }; $convertor = new TreeToArray(); $convertor->onItemAdd[] = function ($item, $level) { $item['level'] = $level; }; return $convertor->convert($tree); }