改名
This commit is contained in:
+11
-6
@@ -11,7 +11,9 @@ namespace Snowflake;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use HttpServer\Server;
|
use HttpServer\Server;
|
||||||
|
use ReflectionException;
|
||||||
use Snowflake\Abstracts\BaseApplication;
|
use Snowflake\Abstracts\BaseApplication;
|
||||||
|
use Snowflake\Exception\NotFindClassException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Init
|
* Class Init
|
||||||
@@ -39,14 +41,17 @@ class Application extends BaseApplication
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param string $service
|
||||||
* @param $service
|
* @return $this
|
||||||
* @return Application
|
* @throws NotFindClassException
|
||||||
* @throws
|
* @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')) {
|
if (method_exists($class, 'onImport')) {
|
||||||
$class->onImport($this);
|
$class->onImport($this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user