[ 'class' => VerbFilter::class, 'actions' => [ 'delete' => ['post'], ], ], 'access' => [ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return $this->getUserModule() ->getAuthorizationChecker() ->isGrantedAsAdministrator($this->getUserCurrent()); } ] ], ], ]; } public function actionIndex() { $dataProviderTaxRate = new ActiveDataProvider([ 'query' => TaxRate::find() ]); return $this->render('index', [ 'dataProviderTaxRate' => $dataProviderTaxRate, ]); } public function actionCreate() { $model = $this-> getTaxRateModule()->instanciateTaxRate(); if ($model->load(\Yii::$app->request->post()) && $model->save()) { $this->setFlash('success', 'Taxe créée.'); return $this->redirect(['index']); } else { return $this->render('create', [ 'model' => $model, ]); } } public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(\Yii::$app->request->post()) && $model->save()) { $this->setFlash('success', 'Taxe éditée.'); return $this->redirect(['index']); } else { return $this->render('update', [ 'model' => $model, ]); } } public function actionDelete(int $id) { $taxRateModule = $this-> getTaxRateModule(); $taxRate = $this->findModel($id); $taxRateModule->delete($taxRate); $this->setFlash('success', 'Taxe supprimé'); return $this->redirect(['tax-rate-admin/index']); } protected function findModel($id) { $taxRateModule = $this-> getTaxRateModule(); if (($taxRate = $taxRateModule->findOneTaxRateById($id)) !== null) { return $taxRate; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }