/** * @param Group $group * @param int $offset */ private function syncGrouphubGroupAdmins(Group $group, $offset = 0) { if (!$this->syncAdmins) { return; } $this->logger->info(' - Processing admins for GrouphubGroup `' . $group->getName() . '` ' . $offset . ' to ' . ($offset + self::BATCH_SIZE) . '...'); $this->ldap->addAdminGroupIfNotExists($group); $grouphubAdmins = $this->api->findGroupUsers($group, $offset, self::BATCH_SIZE, Membership::ROLE_ADMIN); $ldapAdmins = $this->ldap->findGroupAdmins($group, $offset, self::BATCH_SIZE); if (count($grouphubAdmins) === 0 && count($ldapAdmins) === 0) { $this->logger->info(' - Done syncing GroupHubGroup admins!'); return; } $index = $ldapAdmins->synchronize($grouphubAdmins, true); $this->logger->info(' -- Going to add ' . count($ldapAdmins->getAddedElements()) . ' admins for GrouphubGroup to LDAP...'); foreach ($ldapAdmins->getAddedElements() as $element) { /** @var User $element */ $this->ldap->addGroupAdmin($group, $element->getReference()); } $this->logger->info(' -- Going to remove ' . count($ldapAdmins->getRemovedElements()) . ' admins for GrouphubGroup from LDAP...'); foreach ($ldapAdmins->getRemovedElements() as $element) { /** @var User $element */ $this->ldap->removeGroupAdmin($group, $element->getReference()); } $this->syncGrouphubGroupAdmins($group, $offset + $index + 1); }