Files
fastmovieai/fastmovie-admin/plugin/control/expose/api/Control.php
T
李建琦 eae151fd57 FastMovieAI AI短剧创作平台 二开基线
- 源码: xhadmincn/FastMovieAI (Apache 2.0)
- 二开: Docker部署, Swoole改Select, route.php修复, 补update/VERSION
- vendor/示例资源已gitignore
2026-08-26 18:37:36 +08:00

57 lines
1.3 KiB
PHP

<?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;
}
}