| @@ 21-40 (lines=20) @@ | ||
| 18 | * |
|
| 19 | * @return array|bool |
|
| 20 | */ |
|
| 21 | public function set($menus) |
|
| 22 | { |
|
| 23 | if ($menus instanceof Closure) { |
|
| 24 | $menus = $menus($this); |
|
| 25 | } |
|
| 26 | ||
| 27 | if (!is_array($menus)) { |
|
| 28 | $this->setError('子菜单必须是数组或者匿名函数返回数组'); |
|
| 29 | ||
| 30 | return false; |
|
| 31 | } |
|
| 32 | ||
| 33 | $menus = $this->extractMenus($menus); |
|
| 34 | ||
| 35 | $data = ['button' => $menus]; |
|
| 36 | ||
| 37 | $res = $this->_post('create', $data); |
|
| 38 | ||
| 39 | return $res; |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * 获取菜单 |
|
| @@ 118-139 (lines=22) @@ | ||
| 115 | * |
|
| 116 | * @return array|bool |
|
| 117 | */ |
|
| 118 | public function setIndividuationMenu($menus, $matchrule) |
|
| 119 | { |
|
| 120 | if ($menus instanceof Closure) { |
|
| 121 | $menus = $menus($this); |
|
| 122 | } |
|
| 123 | ||
| 124 | if (!is_array($menus)) { |
|
| 125 | $this->setError('子菜单必须是数组或者匿名函数返回数组'); |
|
| 126 | ||
| 127 | return false; |
|
| 128 | } |
|
| 129 | $menus = $this->extractMenus($menus); |
|
| 130 | ||
| 131 | $data = [ |
|
| 132 | 'button' => $menus, |
|
| 133 | 'matchrule' => $matchrule, |
|
| 134 | ]; |
|
| 135 | ||
| 136 | $res = $this->_post('addconditional', $data); |
|
| 137 | ||
| 138 | return $res; |
|
| 139 | } |
|
| 140 | ||
| 141 | /** |
|
| 142 | * 测试个性化菜单匹配结果 |
|