コード例 #1
0
 /**
  * Lists all AuthItem models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new AuthItemSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
コード例 #2
0
 /**
  * Updates an existing AuthItem model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id, $type)
 {
     //        $authItem = $this->findModel($id);
     $authItem = intval($type) === Item::TYPE_PERMISSION ? Yii::$app->authManager->getPermission($id) : Yii::$app->authManager->getRole($id);
     $model = new AuthItemForm();
     $model->scenario = AuthItemForm::SCENARIO_UPDATE;
     if ($model->load(Yii::$app->request->post()) && $model->update()) {
         return $this->redirect(['view', 'id' => $model->name]);
     } else {
         // Setting data model for the form
         $model->name = $authItem->name;
         $model->description = $authItem->description;
         $model->type = $authItem->type;
         $model->data = $authItem->data;
         // Setting data model for the grid
         $searchModel = new AuthItemSearch();
         $searchModel->type = $model->type;
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'AuthItemForm' => $model]);
     }
 }