[ 'class' => VerbFilter::class, 'actions' => [ ], ], 'access' => [ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return $this->getUserManager()->hasAccessBackend(); } ] ], ], ]; } /** * Affiche les utilisateurs ayant accès à l'administration de ce producteur. * Gestion du formulaire permettant d'en ajouter de nouveaux. * * @return string */ public function actionIndex() { $userSearch = new UserSearch(); $usersArray = $userSearch->search()->query->all(); $modelAccessUserProducerForm = new AccessUserProducerForm; if ($modelAccessUserProducerForm->load(\Yii::$app->request->post()) && $modelAccessUserProducerForm->save()) { $this->setFlash('success', 'Droits ajoutés à l\'utilisateur'); } $producer = $this->getProducerCurrent(); $usersAccessArray = $this->getUserManager()->findUsersByProducer($producer->id); return $this->render('index', [ 'usersArray' => $usersArray, 'usersAccessArray' => $usersAccessArray, 'producer' => $producer, 'modelAccessUserProducerForm' => $modelAccessUserProducerForm, ]); } public function actionDelete($idUser) { $userManager = $this->getUserManager(); $user = $userManager->findOneUserById($idUser); if ($user) { $userManager->deleteAccess($user); $this->setFlash('success', 'Droits de l\'utilisateur supprimé.'); } return $this->redirect(['index']); } }