add UserPickerType

This commit is contained in:
2018-04-16 12:03:47 +02:00
parent 7fb2084506
commit f5039cc36f
4 changed files with 70 additions and 4 deletions

View File

@@ -25,6 +25,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Chill\MainBundle\Entity\User;
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
use Symfony\Component\Security\Core\Role\Role;
/**
@@ -96,8 +98,14 @@ class UserPickerType extends AbstractType
->join('ug.permissionsGroup', 'pg')
// role constraints
->join('pg.roleScopes', 'roleScope')
->andWhere($qb->expr()->eq('roleScope.role', ':role'))
->setParameter('role', $options['role'])
->andWhere($qb->expr()->in('roleScope.role', ':roles'))
->setParameter(
'roles',
\array_map(
function(Role $role) { return $role->getRole(); },
$this->authorizationHelper->getParentRoles($options['role'])
)
)
// add active constraint
->andWhere('u.enabled = :enabled')
->setParameter('enabled', true)