mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 15:42:48 +08:00
通过配置项extend_library扩展类似Library目录的命名空间自动定位
This commit is contained in:
@@ -34,6 +34,8 @@ class Loader
|
|||||||
} elseif ($file = self::findFileInComposer($class)) {
|
} elseif ($file = self::findFileInComposer($class)) {
|
||||||
include $file;
|
include $file;
|
||||||
} else {
|
} else {
|
||||||
|
// 项目命名空间
|
||||||
|
$path = APP_PATH;
|
||||||
// 命名空间自动加载
|
// 命名空间自动加载
|
||||||
$name = strtolower(strstr($class, '\\', true));
|
$name = strtolower(strstr($class, '\\', true));
|
||||||
if (isset(self::$namespace[$name])) {
|
if (isset(self::$namespace[$name])) {
|
||||||
@@ -43,8 +45,13 @@ class Loader
|
|||||||
// Library目录下面的命名空间自动定位
|
// Library目录下面的命名空间自动定位
|
||||||
$path = LIB_PATH;
|
$path = LIB_PATH;
|
||||||
} else {
|
} else {
|
||||||
// 项目命名空间
|
$extend = Config::get('extend_library') ?: [];
|
||||||
$path = APP_PATH;
|
foreach ($extend as $_extend) {
|
||||||
|
if (is_dir($_extend . $name)) {
|
||||||
|
$path = $_extend;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$filename = $path . str_replace('\\', DS, str_replace('\\_', '\\', strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $class), "_")))) . EXT;
|
$filename = $path . str_replace('\\', DS, str_replace('\\_', '\\', strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $class), "_")))) . EXT;
|
||||||
if (is_file($filename)) {
|
if (is_file($filename)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user