This commit is contained in:
2023-04-18 10:44:30 +08:00
parent e5f048b778
commit dfc87000c0
+5
View File
@@ -7,6 +7,7 @@ namespace Kiri\Di;
use Exception; use Exception;
use Kiri\Abstracts\Component; use Kiri\Abstracts\Component;
use Kiri\Abstracts\Config;
use ReflectionException; use ReflectionException;
class Scanner extends Component class Scanner extends Component
@@ -69,11 +70,15 @@ class Scanner extends Component
private function load_dir(string $path): void private function load_dir(string $path): void
{ {
$dir = new \DirectoryIterator($path); $dir = new \DirectoryIterator($path);
$skip = Config::get('scanner.skip', []);
foreach ($dir as $value) { foreach ($dir as $value) {
if ($value->isDot() || str_starts_with($value->getFilename(), '.')) { if ($value->isDot() || str_starts_with($value->getFilename(), '.')) {
continue; continue;
} }
if ($value->isDir()) { if ($value->isDir()) {
if (in_array($value->getRealPath() . '/', $skip)) {
continue;
}
$this->load_dir($value->getRealPath()); $this->load_dir($value->getRealPath());
} else if ($value->getExtension() == 'php') { } else if ($value->getExtension() == 'php') {
$this->load_file($value->getRealPath()); $this->load_file($value->getRealPath());