Commit dd4805ad authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Filtrage des rôles pour ne permettre l'association de profil qu'aux rôles non associés

parent 76cd148c
Loading
Loading
Loading
Loading
+2 −1
Changes for module/Application/src/Application/Controller/ProfilController.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ class ProfilController extends AbstractActionController {
        $profilId   = $this->params()->fromRoute('profil');
        $profil     = $this->getProfilService()->getProfil($profilId);

        $roles      = $this->getRoleService()->getRoles();
        $roles      = $this->getRoleService()->getRolesSansProfil();

        return new ViewModel([
            'profil' => $profil,
@@ -133,6 +133,7 @@ class ProfilController extends AbstractActionController {
            if (! $profil->hasRole($role)) {
                $profil->addRole($role);
                $this->getProfilService()->update($profil);
//                $this->getProfilService()->applyProfilToRole($profil, $role);
            }
        }

+15 −0
Changes for module/Application/src/Application/Service/Role/RoleService.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -308,6 +308,21 @@ class RoleService extends BaseService
        return $result;
    }

    /**
     * @return Role[]
     */
    public function getRolesSansProfil()
    {
        $qb = $this->getEntityManager()->getRepository(Role::class)->createQueryBuilder('role')
            ->leftJoin('role.profils', 'profil')
            ->andWhere('profil.id IS NULL')
            ->orderBy('role.roleId', 'ASC')
        ;

        $roles = $qb->getQuery()->getResult();
        return $roles;
    }

//SELECT * FROM ROLE R
//JOIN STRUCTURE S on R.STRUCTURE_ID = S.ID
//LEFT JOIN STRUCTURE_SUBSTIT SS on S.ID = SS.FROM_STRUCTURE_ID