FastMovieAI AI短剧创作平台 二开基线
- 源码: xhadmincn/FastMovieAI (Apache 2.0) - 二开: Docker部署, Swoole改Select, route.php修复, 补update/VERSION - vendor/示例资源已gitignore
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\control\expose\api;
|
||||
|
||||
trait Control
|
||||
{
|
||||
protected $path;
|
||||
/**
|
||||
* 多语言必须在构造函数中设置plugin值为插件名
|
||||
*/
|
||||
protected $plugin;
|
||||
/**
|
||||
* 获取菜单
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getMenus()
|
||||
{
|
||||
clearstatcache();
|
||||
# 当前类的运行目录
|
||||
if (is_file($menu_file = $this->path . '/../control.json')) {
|
||||
return json_decode(file_get_contents($menu_file), true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function getPermissions(){
|
||||
$menus = $this->getMenus();
|
||||
$permissions = [];
|
||||
if($menus){
|
||||
$this->getPath($menus,$permissions);
|
||||
}
|
||||
return $permissions;
|
||||
}
|
||||
public function getPath($arr,&$data)
|
||||
{
|
||||
if(isset($arr['path'])){
|
||||
$data[] = $arr['path'];
|
||||
if(isset($arr['children'])){
|
||||
$this->getPath($arr['children'],$data);
|
||||
}
|
||||
}else{
|
||||
foreach ($arr as $key => $value) {
|
||||
if (isset($value['path'])) {
|
||||
$data[] = $value['path'];
|
||||
}
|
||||
if (isset($value['children'])) {
|
||||
$this->getPath($value['children'],$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function getPlugin()
|
||||
{
|
||||
return $this->plugin;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user