mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-17 20:54:52 +08:00
add runtime preferences config dir fallback
This commit is contained in:
parent
61684d1902
commit
5d6d819ca3
@ -21,7 +21,7 @@ return [
|
|||||||
'source' => [
|
'source' => [
|
||||||
'extensions' => ['php', 'yaml', 'yml', 'json', 'toml'], // 配置文件扩展名
|
'extensions' => ['php', 'yaml', 'yml', 'json', 'toml'], // 配置文件扩展名
|
||||||
'paths' => [
|
'paths' => [
|
||||||
SOURCE_ROOT_DIR . '/config', // 配置文件所在目录
|
\ZM\Framework::getInstance()->runtime_preferences->getConfigDir(), // 配置文件所在目录
|
||||||
// 可以添加多个配置文件目录
|
// 可以添加多个配置文件目录
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@ -56,7 +56,8 @@ class RuntimePreferences
|
|||||||
|
|
||||||
public function getConfigDir(): string
|
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
|
public function withConfigDir(string $config_dir): self
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user