public function setRoles(LdapUserInterface $user)
    {
        $roles = [];

        if ($this->options['default_role']) {
            $roles[] = $this->options['default_role'];
        }
        
        if (!empty($this->options['roles'])) {
            $groups = $this->getGroupsForUser($user);

            foreach ($this->options['roles'] as $role => $roleGroups) {
                if ($this->hasGroupForRoles($roleGroups, $groups)) {
                    $roles[] = $role;
                }
            }
        }

        $user->setRoles($roles);

        return $user;
    }
public function setRoles(LdapUserInterface $user)
    {
        $roles = [];

        if ($this->options['default_role']) {
            $roles[] = $this->options['default_role'];
        }
        
        if (!empty($this->options['roles'])) {
            $groups = $this->getGroupsForUser($user);

            foreach ($this->options['roles'] as $role => $roleGroups) {
                if ($this->hasGroupForRoles($roleGroups, $groups)) {
                    $roles[] = $role;
                }
            }
        }

        $user->setRoles($roles);

        return $user;
    }
public function setRoles ( LdapUserInterface $ user ) { $ roles = [ ] ; if ( $ this -> options [ 'default_role' ] ) { $ roles [ ] = $ this -> options [ 'default_role' ] ; } if ( ! empty ( $ this -> options [ 'roles' ] ) ) { $ groups = $ this -> getGroupsForUser ( $ user ) ; foreach ( $ this -> options [ 'roles' ] as $ role => $ roleGroups ) { if ( $ this -> hasGroupForRoles ( $ roleGroups , $ groups ) ) { $ roles [ ] = $ role ; } } } $ user -> setRoles ( $ roles ) ; return $ user ; }
Set the roles for the user based on LDAP group membership.

@param LdapUserInterface $user
@return LdapUserInterface
Set the roles for the user based on LDAP group membership .