Пример #1
0
 public function actionUpdate($id, $type = null)
 {
     // Find Model
     $model = PermissionService::findById($id);
     // Update/Render if exist
     if (isset($model)) {
         $model->type = $type;
         $model->setScenario('update');
         if ($model->load(Yii::$app->request->post(), 'Permission') && $model->validate()) {
             if (PermissionService::update($model)) {
                 $binder = new Binder();
                 $binder->binderId = $model->id;
                 $binder->load(Yii::$app->request->post(), 'Binder');
                 PermissionService::bindRoles($binder);
                 $this->redirect($this->returnUrl);
             }
         }
         $roles = RoleService::getIdNameListByType($type);
         return $this->render('update', ['model' => $model, 'roles' => $roles]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }