Skip to content

Commit

Permalink
apps的path支持配置为数组
Browse files Browse the repository at this point in the history
  • Loading branch information
HGthecode committed May 6, 2023
1 parent 34c3a9f commit 5bab05f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/parses/ParseApiMenus.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@ public function renderApiMenus(string $appKey): array
$currentApp = $currentAppConfig['appConfig'];
$this->currentApp = $currentApp;

$controllers = [];
if (!empty($currentApp['controllers']) && count($currentApp['controllers']) > 0) {
// 配置的控制器列表
$controllers = $this->getConfigControllers($currentApp['path'],$currentApp['controllers']);
} else {
// 默认读取所有的
}else if(!empty($currentApp['path']) && is_array($currentApp['path']) && count($currentApp['path'])){
// 读取paths的
foreach ($currentApp['path'] as $path) {
$controllersList = $this->getDirControllers($path);
$controllers = array_merge($controllers,$controllersList);
}
} else if(!empty($currentApp['path']) && is_string($currentApp['path'])){
// 默认读取path下所有的
$controllers = $this->getDirControllers($currentApp['path']);
}

$apiData = [];
if (!empty($controllers) && count($controllers) > 0) {
foreach ($controllers as $class) {
Expand Down
9 changes: 8 additions & 1 deletion src/utils/AutoRegisterRouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ public function getAppsApis(){
*/
public function getAppApis($app)
{
$controllers = [];
if (!empty($app['controllers']) && count($app['controllers']) > 0) {
// 配置的控制器列表
$controllers = (new ParseApiMenus($this->config))->getConfigControllers($app['path'],$app['controllers']);
} else {
}else if(!empty($app['path']) && is_array($app['path']) && count($app['path'])){
$parseApiMenus = new ParseApiMenus($this->config);
foreach ($app['path'] as $path) {
$controllersList = $parseApiMenus->getDirControllers($path);
$controllers = array_merge($controllers,$controllersList);
}
} else if(!empty($app['path']) && is_string($app['path'])) {
// 默认读取所有的
$controllers = (new ParseApiMenus($this->config))->getDirControllers($app['path']);
}
Expand Down

0 comments on commit 5bab05f

Please sign in to comment.