You are here

function ldap_user_update_8305 in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_user/ldap_user.install \ldap_user_update_8305()

Converts unreadable integers to strings for LDAP direction.

File

ldap_user/ldap_user.install, line 129

Code

function ldap_user_update_8305() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('ldap_user.settings');
  $mappings = $config
    ->get('ldapUserSyncMappings');
  foreach ($mappings as $direction => $fields) {
    foreach ($fields as $key => $field) {
      if (isset($field['direction'])) {
        if ($field['direction'] == 1 || $field['direction'] == '1') {
          $mappings[$direction][$key]['direction'] = LdapUserAttributesInterface::PROVISION_TO_DRUPAL;
        }
        else {
          $mappings[$direction][$key]['direction'] = LdapUserAttributesInterface::PROVISION_TO_LDAP;
        }
      }
    }
  }
  $keyedMappings[LdapUserAttributesInterface::PROVISION_TO_DRUPAL] = $mappings[1];
  $keyedMappings[LdapUserAttributesInterface::PROVISION_TO_LDAP] = $mappings[2];
  $config
    ->set('ldapUserSyncMappings', $keyedMappings);
  $config
    ->save();
}