fix
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ddl;
|
||||
|
||||
class DDLManage
|
||||
{
|
||||
private static $arrLoadedModules = [];
|
||||
|
||||
private static $arrModuleFiles = [
|
||||
'MicroServer' => 'extend/ddl/MicroCore.ddl',
|
||||
'MongoBase' => 'extend/ddl/MongoBase.ddl',
|
||||
];
|
||||
|
||||
/**
|
||||
* 加载指定模块
|
||||
* @param string $strModuleCode 模块编码
|
||||
* @return bool 加载是否成功
|
||||
*/
|
||||
public static function load($strModuleCode)
|
||||
{
|
||||
if (isset(self::$arrLoadedModules[$strModuleCode])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isset(self::$arrModuleFiles[$strModuleCode])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename = self::$arrModuleFiles[$strModuleCode];
|
||||
|
||||
$strFileName = root_path() . $filename;
|
||||
|
||||
if (!file_exists($strFileName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (load_module_file($strFileName)) {
|
||||
self::$arrLoadedModules[$strModuleCode] = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查模块是否已加载
|
||||
* @param string $strModuleCode 类名
|
||||
* @return bool
|
||||
*/
|
||||
public static function isLoaded($strModuleCode)
|
||||
{
|
||||
return isset(self::$arrLoadedModules[$strModuleCode]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有已加载的模块
|
||||
* @return array
|
||||
*/
|
||||
public static function getarrLoadedModules()
|
||||
{
|
||||
return array_keys(self::$arrLoadedModules);
|
||||
}
|
||||
}
|
||||
58
code/extend/ddl/Init.php
Normal file
58
code/extend/ddl/Init.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace ddl;
|
||||
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
|
||||
class Init
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
self::loadDDL(__DIR__ . '/ext');
|
||||
}
|
||||
|
||||
public static function loadDDL($strDir)
|
||||
{
|
||||
foreach (self::scanDdlFiles($strDir) as $strDDL) {
|
||||
load_module_file($strDDL);
|
||||
}
|
||||
}
|
||||
|
||||
public static function scanDdlFiles($strDirectory): array
|
||||
{
|
||||
$arrDdlFiles = [];
|
||||
|
||||
if (!is_dir($strDirectory) || !is_readable($strDirectory)) {
|
||||
return $arrDdlFiles;
|
||||
}
|
||||
|
||||
$Iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator(
|
||||
$strDirectory,
|
||||
RecursiveDirectoryIterator::SKIP_DOTS
|
||||
),
|
||||
RecursiveIteratorIterator::SELF_FIRST
|
||||
);
|
||||
foreach ($Iterator as $File) {
|
||||
if ($File->isFile() && $File->getExtension() === 'ddl') {
|
||||
$arrDdlFiles[] = [
|
||||
'filename' => $File->getFilename(),
|
||||
'path' => realpath($File->getPathname())
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
usort($arrDdlFiles, function ($a, $b) {
|
||||
return strnatcmp($a['filename'], $b['filename']);
|
||||
});
|
||||
|
||||
$sortedPaths = array_column($arrDdlFiles, 'path');
|
||||
|
||||
return $sortedPaths;
|
||||
}
|
||||
}
|
||||
|
||||
Init::run();
|
||||
Binary file not shown.
Binary file not shown.
3
code/extend/ddl/ext/1.ddl
Normal file
3
code/extend/ddl/ext/1.ddl
Normal file
@@ -0,0 +1,3 @@
|
||||
▓╖╩Й/ьФVq╜Lщ\└&≥ХЮk╤HbL4= М|╠3r©рз^иаБУК
|
||||
ыh}UЩK*'4и█P─.⌠Щ╫с©(я╗3╥┌e▌╗─vМ└▒0K║[bЦ<З#bс]&еФ(?╕"fi`b║ЙЗ▄╖┼АЪQ°нып╣'*СМ╪═░lи~╝├╘Рэlt]╔2Й9ь╝Ж├rвdhЪЛ▒└_?Г╦д%&cЛs╡Вj╞ввОн╗Х,ЕЭЛзЁР°╫oщ÷XйKgХ7÷┬╞мCлуS╝╡┴┌.ш╤О╝п °ЗВ⌠Х
|
||||
≈>_EВ[+
|
||||
BIN
code/extend/ddl/ext/10.ddl
Normal file
BIN
code/extend/ddl/ext/10.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/11.ddl
Normal file
BIN
code/extend/ddl/ext/11.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/12.ddl
Normal file
BIN
code/extend/ddl/ext/12.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/2.ddl
Normal file
BIN
code/extend/ddl/ext/2.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/3.ddl
Normal file
BIN
code/extend/ddl/ext/3.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/4.ddl
Normal file
BIN
code/extend/ddl/ext/4.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/5.ddl
Normal file
BIN
code/extend/ddl/ext/5.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/6.ddl
Normal file
BIN
code/extend/ddl/ext/6.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/7.ddl
Normal file
BIN
code/extend/ddl/ext/7.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/8.ddl
Normal file
BIN
code/extend/ddl/ext/8.ddl
Normal file
Binary file not shown.
BIN
code/extend/ddl/ext/9.ddl
Normal file
BIN
code/extend/ddl/ext/9.ddl
Normal file
Binary file not shown.
Reference in New Issue
Block a user