From 25411d35ebb017e77eef68cd8f9bd78bab826434 Mon Sep 17 00:00:00 2001 From: tale Date: Mon, 27 Mar 2017 10:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=9A=84=E6=A0=B9=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4=E4=B9=9F?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=94=9F=E6=88=90=E7=B1=BB=E5=BA=93=E6=98=A0?= =?UTF-8?q?=E5=B0=84=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../think/console/command/optimize/Autoload.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/library/think/console/command/optimize/Autoload.php b/library/think/console/command/optimize/Autoload.php index 7311aafb..afe7515f 100644 --- a/library/think/console/command/optimize/Autoload.php +++ b/library/think/console/command/optimize/Autoload.php @@ -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: Ambiguous class resolution, "' . $class . '"' . ' was found in both "' . str_replace(["',\n"], [ - '' + '', ], $classMap[$class]) . '" and "' . $path . '", the first will be used.' ); } @@ -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) {