权限节点的更新
This commit is contained in:
@@ -30,22 +30,67 @@ class AuthRule extends Base{
|
||||
array('name'=>'condition','title'=>'条件','type'=>'text','help'=>'')
|
||||
);
|
||||
|
||||
public function uprule($data, $type){
|
||||
public $filter_method = array('__construct', 'execute', 'sqlSplit', 'isMobile', 'is_wechat', '_initialize');
|
||||
|
||||
public function uprule($type){
|
||||
$data = $this->updaterule($type);
|
||||
foreach ($data as $value) {
|
||||
$id = $this->where(array('name' => $value['url']))->value('id');
|
||||
$save = array(
|
||||
'module' => $type,
|
||||
'type' => 2,
|
||||
'name' => $value['url'],
|
||||
'title' => $value['title'],
|
||||
'group' => $value['group'],
|
||||
'status' => 1,
|
||||
);
|
||||
$id = $this->where(array('name' => $value['name']))->value('id');
|
||||
if ($id) {
|
||||
$save['id'] = $id;
|
||||
}
|
||||
$list[] = $save;
|
||||
$list[] = $value;
|
||||
}
|
||||
return $this->saveAll($list);
|
||||
}
|
||||
|
||||
public function updaterule($type){
|
||||
$path = APP_PATH . $type . '/controller';
|
||||
$classname = $this->scanFile($path);
|
||||
foreach ($classname as $value) {
|
||||
$class = "\\app\\" . $type . "\\controller\\" . $value;
|
||||
if(class_exists($class)){
|
||||
$reflection = new \ReflectionClass($class);
|
||||
$group_doc = $this->Parser($reflection->getDocComment());
|
||||
$method = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
|
||||
foreach ($method as $key => $v) {
|
||||
if (!in_array($v->name, $this->filter_method)) {
|
||||
$title_doc = $this->Parser($v->getDocComment());
|
||||
if (isset($title_doc['title']) && $title_doc['title']) {
|
||||
$list[] = array(
|
||||
'module' => $type,
|
||||
'type' => 2,
|
||||
'name' => $type . '/' . strtolower($value) . '/' . strtolower($v->name),
|
||||
'title' => trim($title_doc['title']),
|
||||
'group' => (isset($group_doc['title']) && $group_doc['title']) ? trim($group_doc['title']) : '',
|
||||
'status' => 1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function scanFile($path){
|
||||
$result = array();
|
||||
$files = scandir($path);
|
||||
foreach ($files as $file) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
if (is_dir($path . '/' . $file)) {
|
||||
$this->scanFile($path . '/' . $file);
|
||||
} else {
|
||||
$result[] = substr(basename($file), 0 , -4);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function Parser($text){
|
||||
$doc = new \Doc\Doc();
|
||||
return $doc->parse($text);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user