From bc6f640932d66e3f77b80936b5ddc19f95302a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 2 Sep 2020 18:15: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 --- system/Application.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/system/Application.php b/system/Application.php index d6f429cc..30a645bd 100644 --- a/system/Application.php +++ b/system/Application.php @@ -11,7 +11,9 @@ namespace Snowflake; use Exception; use HttpServer\Server; +use ReflectionException; use Snowflake\Abstracts\BaseApplication; +use Snowflake\Exception\NotFindClassException; /** * Class Init @@ -39,14 +41,17 @@ class Application extends BaseApplication /** - * @param $name - * @param $service - * @return Application - * @throws + * @param string $service + * @return $this + * @throws NotFindClassException + * @throws ReflectionException */ - public function import(string $name, string $service) + public function import(string $service) { - $class = $this->set($name, ['class' => $service]); + if (!class_exists($service)) { + throw new NotFindClassException($service); + } + $class = Snowflake::createObject($service); if (method_exists($class, 'onImport')) { $class->onImport($this); }