This commit is contained in:
2021-04-19 12:43:07 +08:00
parent 4c66dfe0d4
commit 81c5d860c6
+16 -18
View File
@@ -151,16 +151,8 @@ class Loader extends BaseObject
if (!isset($this->_directory[$directory])) { if (!isset($this->_directory[$directory])) {
$this->_directory[$directory] = []; $this->_directory[$directory] = [];
} }
$this->_scanDir($iterator, $namespace); $this->_scanDir($iterator, $namespace);
} else { } else {
$array = explode('/', $path->getRealPath());
array_pop($array);
$directory = implode('/', $array);
$this->_directory[$directory][] = $path->getRealPath();
$this->readFile($path, $namespace); $this->readFile($path, $namespace);
} }
} }
@@ -246,7 +238,6 @@ class Loader extends BaseObject
if (!str_contains($key, $path)) { if (!str_contains($key, $path)) {
continue; continue;
} }
var_dump($_path);
$this->execute($_path); $this->execute($_path);
} }
} catch (Throwable $exception) { } catch (Throwable $exception) {
@@ -279,17 +270,24 @@ class Loader extends BaseObject
*/ */
public function appendFileToDirectory(string $filePath, string $className) public function appendFileToDirectory(string $filePath, string $className)
{ {
$directory = $this->splitDirectory($filePath); $array = explode('/', $filePath);
array_pop($directory); array_pop($array);
$tree = null; $directory = implode('/', $array);
foreach ($directory as $value) {
$tree = $this->getTree($tree, $value);
}
if ($tree instanceof FileTree) { $this->_directory[$directory][] = $className;
$tree->addFile($className, $filePath);
} // $directory = $this->splitDirectory($filePath);
// array_pop($directory);
//
// $tree = null;
// foreach ($directory as $value) {
// $tree = $this->getTree($tree, $value);
// }
//
// if ($tree instanceof FileTree) {
// $tree->addFile($className, $filePath);
// }
} }