Пример #1
0
 /**
  * Enable comments for indicated extension
  *
  * @param string $name Extension name
  *
  * @return boolean Whether extension is saved or not
  */
 public static function enableExtension($name)
 {
     if (isset(self::$extensions[$name])) {
         $model = new Model();
         $model->name = self::$extensions[$name];
         return $model->save();
     }
     return false;
 }
 /**
  * Create model page.
  */
 public function actionCreate()
 {
     $model = new Model(['scenario' => 'admin-create']);
     $statusArray = Model::getStatusArray();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             if ($model->save(false)) {
                 return $this->redirect(['index']);
             } else {
                 Yii::$app->session->setFlash('danger', Module::t('comments-models', 'BACKEND_FLASH_FAIL_ADMIN_CREATE'));
                 return $this->refresh();
             }
         } elseif (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     }
     return $this->render('create', ['model' => $model, 'statusArray' => $statusArray]);
 }