Merge pull request #343 from zhamao-robot/add-runtime-preferences-config-dir-fallback

添加 RuntimePreferences 配置目录回退
This commit is contained in:
sunxyw 2023-03-17 19:04:03 +08:00 committed by GitHub
commit d584b59c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -21,7 +21,7 @@ return [
'source' => [
'extensions' => ['php', 'yaml', 'yml', 'json', 'toml'], // 配置文件扩展名
'paths' => [
SOURCE_ROOT_DIR . '/config', // 配置文件所在目录
\ZM\Framework::getInstance()->runtime_preferences->getConfigDir(), // 配置文件所在目录
// 可以添加多个配置文件目录
],
],

View File

@ -56,7 +56,8 @@ class RuntimePreferences
public function getConfigDir(): string
{
return $this->config_dir;
// fallback to internal config dir if config_dir not exists
return is_dir($this->config_dir) ? $this->config_dir : FRAMEWORK_ROOT_DIR . '/config';
}
public function withConfigDir(string $config_dir): self