[ '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()->getBuilder()->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) { $taxRate = $this->findModel($id); $taxRate->delete(); $this->setFlash('success', 'Taxe supprimé'); return $this->redirect(['tax-rate-admin/index']); } protected function findModel($id) { if (($taxRate = $this->getTaxRateModule()->getRepository()->findOneTaxRateById($id)) !== null) { return $taxRate; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }