| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace addons\Material;
- use common\enums\StatusEnum;
- use common\models\user\UserLevel;
- use Yii;
- use yii\db\Exception;
- use yii\db\Migration;
- use common\helpers\MigrateHelper;
- use common\interfaces\AddonWidget;
- /**
- * 安装
- *
- * Class Install
- * @package addons\Material
- */
- class Install extends Migration implements AddonWidget
- {
- /**
- * @param $addon
- * @return mixed|void
- * @throws \yii\base\InvalidConfigException
- * @throws \yii\web\NotFoundHttpException
- * @throws \yii\web\UnprocessableEntityHttpException
- */
- public function run($addon)
- {
- // MigrateHelper::upByPath([
- // '@addons/Material/console/migrations/'
- // ]);
- }
- public function runApp($mall_id, $addons_name){
- // 基础配置-初始化
- $user_level_list = UserLevel::getUserLevel([['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED]], [], 1,'level,name,id');
- $user_level_ids = implode(',',array_column($user_level_list,'level'));
- $config['basic'] = [
- 'is_audit' => "1",// 是否开启审核
- 'is_filter' => "1",//是否开启敏感词过滤
- 'user_level_limit' => $user_level_ids,//会员发布权限
- 'download_slogans' => '',
- 'is_show_download' => 0,
- 'download_type' => 0,
- 'share_style' => 0,
- ];
- // 保存设置
- $res = Yii::$app->services->setting->addons->set($mall_id, $addons_name, $config);
- if ($res == false) throw new Exception('基础设置保存失败');
- }
- }
|