From e8aeff58e4758c94df269d504d0d06d41a234aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 2 Sep 2020 18:21:22 +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 --- Database/DatabasesProviders.php | 14 +++++++++++++- http-server/ServerProviders.php | 9 ++++++--- system/Abstracts/Providers.php | 17 +++++++++++++++++ system/Application.php | 2 +- 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 system/Abstracts/Providers.php diff --git a/Database/DatabasesProviders.php b/Database/DatabasesProviders.php index 4dfb6f24..5be011f2 100644 --- a/Database/DatabasesProviders.php +++ b/Database/DatabasesProviders.php @@ -6,6 +6,8 @@ namespace Database; use Exception; use Snowflake\Abstracts\Component; +use Snowflake\Abstracts\Providers; +use Snowflake\Application; use Snowflake\Config; use Snowflake\Exception\ConfigException; use Snowflake\Snowflake; @@ -14,10 +16,20 @@ use Snowflake\Snowflake; * Class DatabasesProviders * @package Database */ -class DatabasesProviders extends Component +class DatabasesProviders extends Providers { + /** + * @param Application $application + * @throws Exception + */ + public function onImport(Application $application) + { + $application->set('db', $this); + } + + /** * @param $name * @return DatabasesProviders diff --git a/http-server/ServerProviders.php b/http-server/ServerProviders.php index e5ed69fc..b0d2e725 100644 --- a/http-server/ServerProviders.php +++ b/http-server/ServerProviders.php @@ -7,6 +7,7 @@ namespace HttpServer; use Exception; use HttpServer\Server; use Snowflake\Abstracts\Component; +use Snowflake\Abstracts\Providers; use Snowflake\Config; use Snowflake\Exception\ConfigException; use Snowflake\Snowflake; @@ -15,15 +16,17 @@ use Snowflake\Snowflake; * Class DatabasesProviders * @package Database */ -class ServerProviders extends Component +class ServerProviders extends Providers { + /** + * @param \Snowflake\Application $application * @throws Exception */ - public function onImport() + public function onImport(\Snowflake\Application $application) { - Snowflake::get()->set('server', [ + $application->set('server', [ 'class' => Server::class ]); } diff --git a/system/Abstracts/Providers.php b/system/Abstracts/Providers.php new file mode 100644 index 00000000..3f227d9c --- /dev/null +++ b/system/Abstracts/Providers.php @@ -0,0 +1,17 @@ +onImport($this); }