You are here

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

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

Compute user data.

Parameters

array $test_data: 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 635

Class

ServerTestForm
Use Drupal\Core\Form\FormBase;.

Namespace

Drupal\ldap_servers\Form

Code

private function computeUserData(array $test_data) {
  $rows = [];
  foreach ($test_data['ldap_user']['attr'] as $key => $value) {
    if (is_numeric($key) || $key == 'count') {
    }
    elseif (is_array($value) && count($value) > 1) {
      $count = (int) $value['count'];
      foreach ($value as $i => $value2) {
        if ((string) $i == 'count') {
          continue;
        }
        elseif ($i == 0 && $count == 1) {
          $token = TokenProcessor::PREFIX . $key . TokenProcessor::SUFFIX;
        }
        elseif ($i == 0 && $count > 1) {
          $token = TokenProcessor::PREFIX . $key . TokenProcessor::DELIMITER . '0' . TokenProcessor::SUFFIX;
        }
        elseif ($i == $count - 1 && $count > 1) {
          $token = TokenProcessor::PREFIX . $key . TokenProcessor::DELIMITER . 'last' . TokenProcessor::SUFFIX;
        }
        elseif ($count > 1) {
          $token = TokenProcessor::PREFIX . $key . TokenProcessor::DELIMITER . $i . TokenProcessor::SUFFIX;
        }
        else {
          $token = "";
        }
        $rows[] = [
          'data' => [
            $key,
            $i,
            self::binaryCheck($value2),
            $token,
          ],
        ];
      }
    }
  }
  return $rows;
}