You are here

private function OrphanProcessor::batchQueryUsers in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_user/src/Processor/OrphanProcessor.php \Drupal\ldap_user\Processor\OrphanProcessor::batchQueryUsers()

Batch query for users.

Parameters

int $batch: Batch number.

array $uids: UIDs to process.

Return value

array Queried batch of users.

1 call to OrphanProcessor::batchQueryUsers()
OrphanProcessor::checkOrphans in ldap_user/src/Processor/OrphanProcessor.php
Check for Drupal accounts which no longer have a related LDAP entry.

File

ldap_user/src/Processor/OrphanProcessor.php, line 237

Class

OrphanProcessor
Locates potential orphan user accounts.

Namespace

Drupal\ldap_user\Processor

Code

private function batchQueryUsers(int $batch, array $uids) : array {

  // Creates a list of users in the required format.
  $start = ($batch - 1) * $this->ldapQueryOrLimit;
  $end_plus_1 = min($batch * $this->ldapQueryOrLimit, count($uids));
  $batch_uids = \array_slice($uids, $start, $end_plus_1 - $start);
  $accounts = $this->entityTypeManager
    ->getStorage('user')
    ->loadMultiple($batch_uids);
  $users = [];
  foreach ($accounts as $uid => $user) {

    /** @var \Drupal\user\Entity\User $user */
    $users[] = $this
      ->ldapQueryEligibleUser($uid, $user
      ->get('ldap_user_puid_sid')->value, $user
      ->get('ldap_user_puid_property')->value, $user
      ->get('ldap_user_puid')->value);
  }
  return $users;
}