[ 'class' => VerbFilter::class, 'actions' => [ 'delete' => ['post'], ], ], 'access' => [ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return $this->isUserCurrentAdmin(); } ] ], ], ]; } public function actionIndex() { $dataProviderTaxRate = new ActiveDataProvider([ 'query' => TaxRate::find() ]); return $this->render('index', [ 'dataProviderTaxRate' => $dataProviderTaxRate, ]); } public function actionCreate() { $model = $this->getTaxRateManager()->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) { $taxRateManager = $this->getTaxRateManager(); $taxRate = $this->findModel($id); $taxRateManager->delete($taxRate); $this->setFlash('success', 'Taxe supprimé'); return $this->redirect(['tax-rate-admin/index']); } protected function findModel($id) { $taxRateManager = $this->getTaxRateManager(); if (($taxRate = $taxRateManager->findOneTaxRateById($id)) !== null) { return $taxRate; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }