mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 10:03:49 +00:00
Filter user in user picker by flags, method to get/filter user by flag in UserRepository
This commit is contained in:
@@ -55,7 +55,7 @@ class UserPickerType extends AbstractType
|
||||
|
||||
/**
|
||||
*
|
||||
* @var EntityRepository
|
||||
* @var \Chill\MainBundle\Repository\UserRepository
|
||||
*/
|
||||
protected $userRepository;
|
||||
|
||||
@@ -82,6 +82,8 @@ class UserPickerType extends AbstractType
|
||||
;
|
||||
|
||||
$resolver
|
||||
->setDefault('having_permissions_group_flag', null)
|
||||
->setAllowedTypes('having_permissions_group_flag', ['string', 'null'])
|
||||
->setDefault('class', User::class)
|
||||
->setDefault('placeholder', 'Choose an user')
|
||||
->setDefault('choice_label', function(User $u) {
|
||||
@@ -89,8 +91,16 @@ class UserPickerType extends AbstractType
|
||||
})
|
||||
->setNormalizer('choices', function(Options $options) {
|
||||
|
||||
return $this->authorizationHelper
|
||||
$users = $this->authorizationHelper
|
||||
->findUsersReaching($options['role'], $options['center']);
|
||||
|
||||
if (NULL !== $options['having_permissions_group_flag']) {
|
||||
return $this->userRepository
|
||||
->findUsersHavingFlags($options['having_permissions_group_flag'], $users)
|
||||
;
|
||||
}
|
||||
|
||||
return $users;
|
||||
})
|
||||
;
|
||||
}
|
||||
|
Reference in New Issue
Block a user