This commit is contained in:
2020-09-02 18:15:22 +08:00
parent 5f700016b0
commit bc6f640932
+11 -6
View File
@@ -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);
}