mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-24 00:55:35 +08:00
separate ZMPlugin to traits
This commit is contained in:
@@ -7,6 +7,7 @@ namespace ZM;
|
|||||||
use ZM\Command\Server\ServerStartCommand;
|
use ZM\Command\Server\ServerStartCommand;
|
||||||
use ZM\Exception\SingletonViolationException;
|
use ZM\Exception\SingletonViolationException;
|
||||||
use ZM\Plugin\PluginManager;
|
use ZM\Plugin\PluginManager;
|
||||||
|
use ZM\Plugin\PluginMeta;
|
||||||
use ZM\Plugin\ZMPlugin;
|
use ZM\Plugin\ZMPlugin;
|
||||||
|
|
||||||
class ZMApplication extends ZMPlugin
|
class ZMApplication extends ZMPlugin
|
||||||
@@ -20,13 +21,12 @@ class ZMApplication extends ZMPlugin
|
|||||||
/**
|
/**
|
||||||
* @throws SingletonViolationException
|
* @throws SingletonViolationException
|
||||||
*/
|
*/
|
||||||
public function __construct(mixed $dir = null)
|
public function __construct()
|
||||||
{
|
{
|
||||||
if (self::$obj !== null) {
|
if (self::$obj !== null) {
|
||||||
throw new SingletonViolationException(self::class);
|
throw new SingletonViolationException(self::class);
|
||||||
}
|
}
|
||||||
self::$obj = $this; // 用于标记已经初始化完成
|
self::$obj = $this; // 用于标记已经初始化完成
|
||||||
parent::__construct($dir ?? (__DIR__ . '/../..'));
|
|
||||||
$this->args = ServerStartCommand::exportOptionArray();
|
$this->args = ServerStartCommand::exportOptionArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,9 @@ class ZMApplication extends ZMPlugin
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
PluginManager::addPlugin(['name' => 'native-app', 'object' => $this]);
|
$meta = new PluginMeta(['name' => 'native'], ZM_PLUGIN_TYPE_NATIVE);
|
||||||
|
$meta->bindEntity($this);
|
||||||
|
PluginManager::addPlugin($meta);
|
||||||
(new Framework($this->args))->init()->start();
|
(new Framework($this->args))->init()->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user