From f527ac08dda150836fdf2a182449c58ae57e237e Mon Sep 17 00:00:00 2001 From: chenlong Date: Wed, 27 Sep 2023 11:51:59 +0800 Subject: [PATCH] s --- Service/ApiDocService.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Service/ApiDocService.php b/Service/ApiDocService.php index c6ecbe4..753173e 100644 --- a/Service/ApiDocService.php +++ b/Service/ApiDocService.php @@ -25,13 +25,15 @@ class ApiDocService { use AopProxyTrait; + private array $config = []; + /** * @throws \Exception */ public function get(): array { $appName = Hy::config('app_name', ''); - $getPath = Hy::config('plugins.ApiDoc.get_path', []); + $getPath = $this->getDefaultConfig('get_path'); $apiLists = $this->scan($getPath); @@ -43,6 +45,20 @@ class ApiDocService ]; } + /** + * @param string|null $key + * + * @return array|mixed + */ + private function getDefaultConfig(string $key = null): mixed + { + if (!$this->config) { + $this->config = Hy::config('plugins.ApiDoc') ?: include __DIR__ . '/../config.php'; + } + + return $key === null ? $this->config : $this->config[$key]; + } + /** * @param array $paths *