mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-18 13:14:52 +08:00
add yaml and toml config support
This commit is contained in:
parent
b09d12aad5
commit
5d8a1deb35
@ -274,10 +274,26 @@ class RefactoredConfig
|
||||
break;
|
||||
case 'yaml':
|
||||
case 'yml':
|
||||
// TODO: 实现yaml解析
|
||||
$yaml_parser_class = 'Symfony\Component\Yaml\Yaml';
|
||||
if (!class_exists($yaml_parser_class)) {
|
||||
throw ConfigException::loadConfigFailed($path, 'YAML 解析器未安装');
|
||||
}
|
||||
try {
|
||||
$config = $yaml_parser_class::parse($content);
|
||||
} catch (\RuntimeException $e) {
|
||||
throw ConfigException::loadConfigFailed($path, $e->getMessage());
|
||||
}
|
||||
break;
|
||||
case 'toml':
|
||||
// TODO: 实现toml解析
|
||||
$toml_parser_class = 'Yosymfony\Toml\Toml';
|
||||
if (!class_exists($toml_parser_class)) {
|
||||
throw ConfigException::loadConfigFailed($path, 'TOML 解析器未安装');
|
||||
}
|
||||
try {
|
||||
$config = $toml_parser_class::parse($content);
|
||||
} catch (\RuntimeException $e) {
|
||||
throw ConfigException::loadConfigFailed($path, $e->getMessage());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw ConfigException::unsupportedFileType($path);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user