/**
  * 前端初始化之一:检测主题设置
  *
  * 独立出来的原因是不想在init中直接抛出异常。。。
  *
  * @param string $theme
  * @return bool
  * @throws InvalidConfigException
  */
 public function setTheme($theme)
 {
     $themes = CMSUtils::getThemeList();
     if ($theme != '[none]' && !in_array($theme, $themes)) {
         throw new InvalidConfigException("错误的配置项,不支持的主题类型:「{$theme」。}");
     }
     if ($theme != '[none]') {
         $this->view->theme = Yii::createObject(['class' => '\\yii\\base\\Theme', 'pathMap' => ['@app/views' => "@app/themes/{$theme}/views"]]);
     }
     return true;
 }
 /**
  * Base Setting
  * 基本设置
  */
 public function actionSetting()
 {
     $setting = new SettingForm();
     $setting->load(CMSUtils::getSiteConfig('sys'), '');
     $setting->setOldAttributes($setting->attributes);
     $themes = array('[none]' => '不使用主题');
     $themes += CMSUtils::getThemeList();
     if ($setting->load(Yii::$app->request->post())) {
         if (!isset($themes[$setting->theme])) {
             $setting->addError('theme', '指定主题不存在!');
             $setting->theme = '[none]';
         } else {
             if ($setting->save('sys')) {
                 Yii::$app->cache->set('config_sys', $setting->attributes);
             }
         }
     }
     return $this->render('setting', ['model' => $setting, 'themes' => $themes]);
 }