mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-22 16:15:34 +08:00
add PluginMeta to format plugin meta information
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\Plugin\Traits;
|
||||
|
||||
use ZM\Annotation\OneBot\BotCommand;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\Plugin\Traits;
|
||||
|
||||
use ZM\Annotation\Framework\Cron;
|
||||
@@ -13,7 +15,6 @@ trait CronTrait
|
||||
* 添加一个计划任务
|
||||
*
|
||||
* @param Cron $cron 计划任务注解对象
|
||||
* @return void
|
||||
*/
|
||||
public function addCron(Cron $cron): void
|
||||
{
|
||||
@@ -22,7 +23,6 @@ trait CronTrait
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @return array
|
||||
*/
|
||||
public function getCrons(): array
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\Plugin\Traits;
|
||||
|
||||
trait EventTrait
|
||||
|
||||
37
src/ZM/Plugin/Traits/InitTrait.php
Normal file
37
src/ZM/Plugin/Traits/InitTrait.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\Plugin\Traits;
|
||||
|
||||
use ZM\Annotation\Framework\Init;
|
||||
|
||||
trait InitTrait
|
||||
{
|
||||
/** @var Init[] 插件启动回调 */
|
||||
protected array $on_init = [];
|
||||
|
||||
/**
|
||||
* 设置当前插件的加载后的初始化回调
|
||||
*
|
||||
* @param callable $callback 回调函数
|
||||
* @param int $worker_id 所在的 Worker 进程,默认在 #0
|
||||
* @param int $level 优先级
|
||||
*/
|
||||
public function onInit(callable $callback, int $worker_id = 0, int $level = 20): void
|
||||
{
|
||||
$init = new Init($worker_id, $level);
|
||||
$init->on($callback);
|
||||
$this->on_init[] = $init;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取初始化注解事件回调
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getInits(): array
|
||||
{
|
||||
return $this->on_init;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\Plugin\Traits;
|
||||
|
||||
use ZM\Annotation\AnnotationParser;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\Plugin\Traits;
|
||||
|
||||
use ZM\Annotation\Http\Route;
|
||||
@@ -19,7 +21,6 @@ trait RouteTrait
|
||||
$this->routes[] = $route;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user