コード例 #1
0
 /**
  * @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;
 }
コード例 #2
0
 /**
  * @return Tree
  */
 public function create()
 {
     $tree = $this->menuTreeFactory->create($this->sectionId);
     $tree->onNodeCreated[] = function ($item, $data) {
         $item->priority = $data['priority'];
     };
     return $tree;
 }
コード例 #3
0
 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');
     }
 }
コード例 #4
0
 /**
  * @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);
 }