[ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return $this->getUserModule() ->getAuthorizationChecker() ->isGrantedAsProducer($this->getUserCurrent()); } ] ], ], ]; } public function actionIndex() { $model = new UserImportUploadForm(); if ($model->load(\Yii::$app->request->post())) { $model->file = UploadedFile::getInstance($model, 'file'); if($model->file && $model->validate()) { try { $this->getUserModule()->getBulkImporter()->import( $model->file->tempName, (bool) $model->send_mail_welcome ); $this->setFlash('success', "Fichier importé."); } catch(ErrorException $exception) { $this->setFlash('error', $exception->getMessage()); } } } return $this->render('index', [ 'model' => $model ]); } }