예제 #1
0
 /**
  * @inheritdoc
  */
 public function run($tab = '')
 {
     if (!$this->checkSectionAccess($tab)) {
         throw new ForbiddenHttpException();
     }
     $this->controller->getView()->title = $this->title;
     $this->_tab = $tab;
     if (Yii::$app->request->isPost) {
         $post = Yii::$app->request->post();
         $section = ArrayHelper::getValue($post, 'section', Param::DEFAULT_SECTION);
         /** @var $configs Config[] */
         $configs = Param::getConfigsBySection($section);
         if (Config::loadMultiple($configs, $post)) {
             Config::validateMultiple($configs);
             /** @var $config Config */
             foreach ($configs as $config) {
                 $isDirty = $config->getDirtyAttributes(['value']);
                 if (!$config->getErrors() && $isDirty && Param::isAccess($config) && $config->save(false, ['value'])) {
                     $this->controller->addFlash(Controller::FLASH_SUCCESS, Yii::t('app', '<b>{title}</b> updated.', ['title' => $config->title]));
                 }
             }
             $this->_configs[$section] = $configs;
         }
     }
     $this->tabsOptions['items'] = $this->renderTabs();
     return $this->controller->renderContent(Tabs::widget($this->tabsOptions));
 }