You are here

private function ServerTestForm::computeUserData in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_servers/src/Form/ServerTestForm.php \Drupal\ldap_servers\Form\ServerTestForm::computeUserData()

Compute user data.

Parameters

\Symfony\Component\Ldap\Entry $ldap_entry: Data to test on.

Return value

array Computed data.

1 call to ServerTestForm::computeUserData()
ServerTestForm::buildForm in ldap_servers/src/Form/ServerTestForm.php
Form constructor.

File

ldap_servers/src/Form/ServerTestForm.php, line 733

Class

ServerTestForm
Use Drupal\Core\Form\FormBase;.

Namespace

Drupal\ldap_servers\Form

Code

private function computeUserData(Entry $ldap_entry) : array {
  $rows = [];
  foreach ($ldap_entry
    ->getAttributes() as $attribute_key => $attribute_value) {
    foreach ($attribute_value as $item_key => $item_value) {
      $item_value = self::binaryCheck($item_value);
      $token = '';
      if (count($attribute_value) === 1) {
        $token = sprintf('[%s]', $attribute_key);
      }
      if (count($attribute_value) > 1) {
        if ($item_key === count($attribute_value) - 1) {
          $token = sprintf('[%s:last]', $attribute_key);
          $rows[] = [
            'data' => [
              $attribute_key,
              $item_key,
              $item_value,
              $token,
            ],
          ];
        }
        $token = sprintf('[%s:%s]', $attribute_key, $item_key);
      }
      $rows[] = [
        'data' => [
          $attribute_key,
          $item_key,
          $item_value,
          $token,
        ],
      ];
    }
  }
  return $rows;
}