From 4a72b0bdc26771df84d19af9c004165df5d02db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 19 Apr 2021 11:50:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Annotation/Loader.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Annotation/Loader.php b/Annotation/Loader.php index 9f28aae3..9ed8e12b 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -27,6 +27,9 @@ class Loader extends BaseObject private array $_fileMap = []; + private array $_directory = []; + + private FileTree $files; @@ -136,8 +139,17 @@ class Loader extends BaseObject if ($path->isDir()) { $iterator = new DirectoryIterator($path->getRealPath()); $this->_scanDir($iterator, $namespace); + + $this->_directory[rtrim($path->getRealPath(), '/')] = []; } else { $this->readFile($path, $namespace); + + $array = explode('/', $path->getRealPath()); + array_pop($array); + + $directory = '/' . implode('/', $array); + + $this->_directory[$directory][] = $directory; } } } @@ -214,7 +226,15 @@ class Loader extends BaseObject public function loadByDirectory(string $path, ?string $outPath = null) { try { - $this->each($path, $outPath); + $path = '/' . trim($path, '/'); + if (!isset($this->_directory[$path])) { + return; + } + $this->execute($this->_directory[$path]); +// +// foreach ($this->_directory[$path] as $file) { +// } +// $this->each($path, $outPath); } catch (Throwable $exception) { $this->addError($exception, 'throwable'); }