Пример #1
0
 public function actionUpdate()
 {
     $meta = new ModelMeta();
     $meta->setScenario("update");
     if ($meta->load(Yii::$app->request->post(), "ModelMeta")) {
         if (SiteService::updateMeta($meta)) {
             return AjaxUtil::generateSuccess(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::MESSAGE_REQUEST), $meta);
         }
     }
     return AjaxUtil::generateFailure(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_REQUEST));
 }
Пример #2
0
 public function actionUpdate($type)
 {
     $settings = SiteService::getAttributeMapBySlugType(Yii::$app->cmgCore->getSiteSlug(), $type);
     $fieldsMap = FormUtil::fillFromModelAttribute("config-{$type}", $settings);
     $model = new GenericForm(['fields' => $fieldsMap]);
     if ($model->load(Yii::$app->request->post(), 'GenericForm') && $model->validate()) {
         $settings = FormUtil::getModelAttributes($model, $settings);
         ModelAttributeService::updateAll($settings);
         return $this->redirect("index?type={$type}");
     }
     return $this->render('update', ['model' => $model, 'type' => $type]);
 }
Пример #3
0
 public function actionDelete($id)
 {
     // Find Model
     $model = SiteService::findById($id);
     // Delete/Render if exist
     if (isset($model)) {
         if ($model->load(Yii::$app->request->post(), 'Site')) {
             try {
                 SiteService::delete($model);
                 return $this->redirect('all');
             } catch (Exception $e) {
                 throw new HttpException(409, Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_DEPENDENCY));
             }
         }
         $avatar = $model->avatar;
         $banner = $model->banner;
         return $this->render('delete', ['model' => $model, 'avatar' => $avatar, 'banner' => $banner]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }