From 480abf2d282ee7c1e0424a3fe2cbb41e444893b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 15 Sep 2020 19:26:44 +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 --- System/Application.php | 22 ++++++++++++++++++++++ function.php | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/System/Application.php b/System/Application.php index 3d96e15f..67d4b6a7 100644 --- a/System/Application.php +++ b/System/Application.php @@ -38,6 +38,17 @@ class Application extends BaseApplication public $id = 'uniqueId'; + /** + * Application constructor. + * @param array $config + */ + public function __construct(array $config = []) + { + $this->scanning(); + parent::__construct($config); + } + + /** * @throws ConfigException * @throws NotFindClassException @@ -109,6 +120,17 @@ class Application extends BaseApplication } + /** + * + */ + private function scanning() + { + $this->debug('start scanning...'); + loadByDir(__DIR__ . '/../'); + $this->debug('scanning end...'); + } + + /** * @param $className * @param null $abstracts diff --git a/function.php b/function.php index e8956c07..60fb7878 100644 --- a/function.php +++ b/function.php @@ -32,6 +32,27 @@ if (!function_exists('make')) { } +} + +if (!function_exists('loadByDir')) { + + + /** + * @param $path + */ + function loadByDir($path) + { + $path = rtrim($path, '/'); + foreach (glob($path . '/*') as $value) { + if (is_dir($value)) { + loadByDir($value); + }else{ + include_once "$value"; + } + } + } + + }