优化开启/关闭模块

This commit is contained in:
JaguarJack
2020-06-24 10:07:11 +08:00
parent f6783cb13e
commit 5f5260a639
3 changed files with 86 additions and 7 deletions

View File

@@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catcher\command\install;
use catcher\CatchAdmin;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
class DisableModuleCommand extends Command
{
protected function configure()
{
$this->setName('disable:module')
->addArgument('module', Argument::REQUIRED, 'module name')
->setDescription('disable catch module');
}
protected function execute(Input $input, Output $output)
{
$module = $input->getArgument('module');
//dd($module, 123);
if (empty(CatchAdmin::getModuleInfo(CatchAdmin::directory() .$module))) {
$output->error("module [$module] not exist");
} else {
CatchAdmin::disableModule($module);
$output->info("module [$module] disabled");
}
}
}

View File

@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catcher\command\install;
use catcher\CatchAdmin;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;
class EnableModuleCommand extends Command
{
protected function configure()
{
$this->setName('enable:module')
->addArgument('module', Argument::REQUIRED, 'module name')
->setDescription('enable catch module');
}
protected function execute(Input $input, Output $output)
{
$module = $input->getArgument('module');
if (empty(CatchAdmin::getModuleInfo(CatchAdmin::directory() .$module))) {
$output->error("module [$module] not exist");
} else {
CatchAdmin::enableModule($module);
$output->info("module [$module] enabled");
}
}
}