mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-24 00:55:35 +08:00
add plugin command bootstrappers
This commit is contained in:
@@ -7,6 +7,7 @@ namespace ZM\Command;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use ZM\Framework;
|
||||
|
||||
abstract class Command extends \Symfony\Component\Console\Command\Command implements LoggerInterface
|
||||
{
|
||||
@@ -62,4 +63,9 @@ abstract class Command extends \Symfony\Component\Console\Command\Command implem
|
||||
* @return int 命令执行结果 {@see self::SUCCESS} 或 {@see self::FAILURE} 或 {@see self::INVALID}
|
||||
*/
|
||||
abstract protected function handle(): int;
|
||||
|
||||
protected function emitBootstrap(string $class): void
|
||||
{
|
||||
Framework::getInstance()->bootstrap($class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,15 @@ use ZM\Plugin\PluginManager;
|
||||
|
||||
abstract class PluginCommand extends Command
|
||||
{
|
||||
protected array $bootstrappers = [
|
||||
BootStrap\RegisterLogger::class,
|
||||
Bootstrap\SetInternalTimezone::class,
|
||||
Bootstrap\LoadConfiguration::class,
|
||||
Bootstrap\LoadPlugins::class,
|
||||
];
|
||||
|
||||
/** @var null|string 动态插件和 Phar 插件的加载目录 */
|
||||
protected ?string $plugin_dir = null;
|
||||
|
||||
public function __construct(string $name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
$this->emitBootstrap(Bootstrap\LoadPlugins::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件名称合规验证器
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user