setName('UpdateConfigTab') ->setDescription('CPS测试功能配置,如果系统配置中没有CPS测试功能配置则添加一个Tab'); } /** * 执行指令 * @param Input $input * @param Output $output * @return null|int * @throws \LogicException * @see setCode() */ protected function execute(Input $input, Output $output) { //cli模式下无法获取到当前的项目模块,手动指定一下 Request::instance()->module('admin'); $model = new ConfigModel(); $obj = $model->where('name', 'eq', 'configgroup')->find(); if(!in_array('cpstest', json_decode($obj->value, true))){ $config_arr = json_decode($obj->value, true); $config_arr['cpstest'] = 'CPS测试功能配置'; $rst = $model->update(['value'=>json_encode($config_arr)], ['name'=>'configgroup']); // is_open_share share_channels share_domain share_content share_book_id share_chapter_num Redis::instance()->del('site'); $output->writeln('Test'.json_encode($rst)); } } }