update to 3.0.0-alpha2 (build 610): refactor driver

This commit is contained in:
crazywhalecc
2022-08-01 16:31:54 +08:00
committed by Jerry Ma
parent f2a12634a4
commit 41b058aeaf
186 changed files with 1922 additions and 15444 deletions

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace ZM\Config;
use ZM\Exception\ConfigException;
use ZM\Utils\DataProvider;
use ZM\Store\FileSystem;
class ZMConfig
{
@@ -22,7 +22,7 @@ class ZMConfig
public static $config = [];
/** @var string 配置文件 */
private static $path = '.';
private static $path = 'config';
/** @var string 上次的路径 */
private static $last_path = '.';
@@ -187,7 +187,7 @@ class ZMConfig
private static function parseList(string $name): void
{
$list = [];
$files = DataProvider::scanDirFiles(self::$path, true, true);
$files = FileSystem::scanDirFiles(self::$path, true, true);
foreach ($files as $file) {
logger()->debug('正在从目录' . self::$path . '读取配置文件 ' . $file);
$info = pathinfo($file);
@@ -227,15 +227,15 @@ class ZMConfig
logger()->warning('文件名 ' . $info['filename'] . ' 不合法(含有"."),请检查文件名是否合法。');
continue;
}
$obj->path = realpath(self::$path . '/' . $info['dirname'] . '/' . $info['basename']);
$obj->path = zm_dir(self::$path . '/' . $info['dirname'] . '/' . $info['basename']);
$obj->extension = $ext;
$obj->data = self::readConfigFromFile(realpath(self::$path . '/' . $info['dirname'] . '/' . $info['basename']), $info['extension']);
$obj->data = self::readConfigFromFile(zm_dir(self::$path . '/' . $info['dirname'] . '/' . $info['basename']), $info['extension']);
$list[] = $obj;
}
}
// 如果是源码模式config目录和default目录相同所以不需要继续采摘default目录下的文件
if (realpath(self::$path) !== realpath(self::DEFAULT_PATH)) {
$files = DataProvider::scanDirFiles(self::DEFAULT_PATH, true, true);
$files = FileSystem::scanDirFiles(self::DEFAULT_PATH, true, true);
foreach ($files as $file) {
$info = pathinfo($file);
$info['extension'] = $info['extension'] ?? '';
@@ -249,7 +249,7 @@ class ZMConfig
$obj->is_env = false;
$obj->path = realpath(self::DEFAULT_PATH . '/' . $info['dirname'] . '/' . $info['basename']);
$obj->extension = $info['extension'];
$obj->data = self::readConfigFromFile(realpath(self::DEFAULT_PATH . '/' . $info['dirname'] . '/' . $info['basename']), $info['extension']);
$obj->data = self::readConfigFromFile(zm_dir(self::DEFAULT_PATH . '/' . $info['dirname'] . '/' . $info['basename']), $info['extension']);
$list[] = $obj;
}
}