From e88166e6db57c0caa70e6566278658d654f78967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 19 Apr 2021 15:42:40 +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 | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Annotation/Loader.php b/Annotation/Loader.php index 33145fb6..3e17ae14 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -230,20 +230,25 @@ class Loader extends BaseObject public function loadByDirectory(string $path, string|array $outPath = '') { try { -// $path = '/' . trim($path, '/'); -// if (!isset($this->_directory[$path])) { -// return; -// } -// foreach ($this->_directory as $key => $_path) { -// $key = '/' . trim($path, '/'); -// if (!str_starts_with($key, $path)) { -// continue; -// } -//// if (!empty($outPath) && in_array($key, $outPath)) continue; -// $this->execute($_path); -// } + $path = '/' . trim($path, '/'); + if (!isset($this->_directory[$path])) { + return; + } + if (empty($outPath)) { + $outPath = []; + } else if (is_string($outPath)) { + $outPath = [$outPath]; + } + foreach ($this->_directory as $key => $_path) { + $key = '/' . trim($key, '/'); + if (!str_starts_with($key, $path)) { + continue; + } + if (in_array($key, $outPath)) continue; + $this->execute($_path); + } - $this->each($path, $outPath); +// $this->each($path, $outPath); } catch (Throwable $exception) { $this->addError($exception, 'throwable'); }