mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
支持自定义的根命名空间也可以生成类库映射缓存
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
namespace think\console\command\optimize;
|
||||
|
||||
use think\App;
|
||||
use think\Config;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
@@ -32,7 +33,7 @@ class Autoload extends Command
|
||||
/**
|
||||
* 类库映射
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
EOF;
|
||||
@@ -42,9 +43,14 @@ EOF;
|
||||
'think\\' => LIB_PATH . 'think',
|
||||
'behavior\\' => LIB_PATH . 'behavior',
|
||||
'traits\\' => LIB_PATH . 'traits',
|
||||
'' => realpath(rtrim(EXTEND_PATH))
|
||||
'' => realpath(rtrim(EXTEND_PATH)),
|
||||
];
|
||||
|
||||
$root_namespace = Config::get('root_namespace');
|
||||
foreach ($root_namespace as $namespace => $dir) {
|
||||
$namespacesToScan[$namespace . '\\'] = realpath($dir);
|
||||
}
|
||||
|
||||
krsort($namespacesToScan);
|
||||
$classMap = [];
|
||||
foreach ($namespacesToScan as $namespace => $dir) {
|
||||
@@ -84,7 +90,7 @@ EOF;
|
||||
$this->output->writeln(
|
||||
'<warning>Warning: Ambiguous class resolution, "' . $class . '"' .
|
||||
' was found in both "' . str_replace(["',\n"], [
|
||||
''
|
||||
'',
|
||||
], $classMap[$class]) . '" and "' . $path . '", the first will be used.</warning>'
|
||||
);
|
||||
}
|
||||
@@ -99,6 +105,7 @@ EOF;
|
||||
$appPath = $this->normalizePath(realpath(APP_PATH));
|
||||
$libPath = $this->normalizePath(realpath(LIB_PATH));
|
||||
$extendPath = $this->normalizePath(realpath(EXTEND_PATH));
|
||||
$rootPath = $this->normalizePath(realpath(ROOT_PATH));
|
||||
$path = $this->normalizePath($path);
|
||||
|
||||
if (strpos($path, $libPath . '/') === 0) {
|
||||
@@ -110,6 +117,9 @@ EOF;
|
||||
} elseif (strpos($path, $extendPath . '/') === 0) {
|
||||
$path = substr($path, strlen($extendPath) + 1);
|
||||
$baseDir = 'EXTEND_PATH';
|
||||
} elseif (strpos($path, $rootPath . '/') === 0) {
|
||||
$path = substr($path, strlen($rootPath) + 1);
|
||||
$baseDir = 'ROOT_PATH';
|
||||
}
|
||||
|
||||
if ($path !== false) {
|
||||
|
||||
Reference in New Issue
Block a user