catchAdmin/extend/catcher/command/install/EnableModuleCommand.php
2020-07-01 15:47:06 +08:00

41 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 catchAdmin\permissions\model\Permissions;
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);
app(Permissions::class)->restore(['module' => trim($module)]);
$output->info("module [$module] enabled");
}
}
}