Skip to content

Commit 5bab05f

Browse files
committed
apps的path支持配置为数组
1 parent 34c3a9f commit 5bab05f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/parses/ParseApiMenus.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,20 @@ public function renderApiMenus(string $appKey): array
4343
$currentApp = $currentAppConfig['appConfig'];
4444
$this->currentApp = $currentApp;
4545

46+
$controllers = [];
4647
if (!empty($currentApp['controllers']) && count($currentApp['controllers']) > 0) {
4748
// 配置的控制器列表
4849
$controllers = $this->getConfigControllers($currentApp['path'],$currentApp['controllers']);
49-
} else {
50-
// 默认读取所有的
50+
}else if(!empty($currentApp['path']) && is_array($currentApp['path']) && count($currentApp['path'])){
51+
// 读取paths的
52+
foreach ($currentApp['path'] as $path) {
53+
$controllersList = $this->getDirControllers($path);
54+
$controllers = array_merge($controllers,$controllersList);
55+
}
56+
} else if(!empty($currentApp['path']) && is_string($currentApp['path'])){
57+
// 默认读取path下所有的
5158
$controllers = $this->getDirControllers($currentApp['path']);
5259
}
53-
5460
$apiData = [];
5561
if (!empty($controllers) && count($controllers) > 0) {
5662
foreach ($controllers as $class) {

src/utils/AutoRegisterRouts.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,17 @@ public function getAppsApis(){
5252
*/
5353
public function getAppApis($app)
5454
{
55+
$controllers = [];
5556
if (!empty($app['controllers']) && count($app['controllers']) > 0) {
5657
// 配置的控制器列表
5758
$controllers = (new ParseApiMenus($this->config))->getConfigControllers($app['path'],$app['controllers']);
58-
} else {
59+
}else if(!empty($app['path']) && is_array($app['path']) && count($app['path'])){
60+
$parseApiMenus = new ParseApiMenus($this->config);
61+
foreach ($app['path'] as $path) {
62+
$controllersList = $parseApiMenus->getDirControllers($path);
63+
$controllers = array_merge($controllers,$controllersList);
64+
}
65+
} else if(!empty($app['path']) && is_string($app['path'])) {
5966
// 默认读取所有的
6067
$controllers = (new ParseApiMenus($this->config))->getDirControllers($app['path']);
6168
}

0 commit comments

Comments
 (0)