This commit is contained in:
2021-04-14 18:13:17 +08:00
parent 61950d9290
commit 91a2899840
2 changed files with 14 additions and 4 deletions
+12 -2
View File
@@ -211,7 +211,7 @@ class Loader extends BaseObject
public function loadByDirectory(string $path, ?string $outPath = null)
{
try {
$this->each($path);
$this->each($path, $outPath);
} catch (Throwable $exception) {
$this->addError($exception, 'throwable');
}
@@ -258,14 +258,24 @@ class Loader extends BaseObject
/**
* @param string $filePath
* @param string|null $outPath
* @return $this
*/
private function each(string $filePath): static
private function each(string $filePath, ?string $outPath): static
{
$tree = null;
$directory = $this->splitDirectory($filePath);
if (!empty($outPath)) {
$outPath = rtrim($outPath, '/');
}
$_tmp = '';
foreach ($directory as $key => $value) {
$_tmp .= DIRECTORY_SEPARATOR . $value;
if (str_contains($_tmp, $outPath)) {
break;
}
$tree = $this->getTree($tree, $value);
}
if ($tree instanceof FileTree) {