Ejemplo n.º 1
0
 /**
  * Deletes an existing Game model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @return mixed
  */
 public function actionDelete()
 {
     $rr = new RequestResponse();
     if ($rr->isRequestAjaxPost()) {
         try {
             $model = $this->model;
             $id = $model->name;
             $model = $this->findModel($id);
             if (!in_array($model->item->name, CmsManager::protectedPermissions())) {
                 if (\Yii::$app->getAuthManager()->remove($model->item)) {
                     $rr->message = \Yii::t('app', 'Record deleted successfully');
                     $rr->success = true;
                 } else {
                     $rr->message = \Yii::t('app', 'Record deleted unsuccessfully');
                     $rr->success = false;
                 }
             } else {
                 $rr->message = \Yii::t('app', 'This entry can not be deleted!');
                 $rr->success = false;
             }
         } catch (\Exception $e) {
             $rr->message = $e->getMessage();
             $rr->success = false;
         }
         return (array) $rr;
     }
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function removeChildren($parent)
 {
     $result = parent::removeChildren($parent);
     if ($this->_children !== null) {
         unset($this->_children[$parent->name]);
     }
     $this->invalidate(self::PART_CHILDREN);
     return $result;
 }