You are here

function ldap_user_update_8306 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_8306()

Converts unreadable integers to strings for LDAP provision triggers.

File

ldap_user/ldap_user.install, line 155

Code

function ldap_user_update_8306() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('ldap_user.settings');
  $existingDrupalTriggers = $config
    ->get('drupalAcctProvisionTriggers');
  $newDrupalTriggers = [];
  foreach ($existingDrupalTriggers as $index => $trigger) {
    switch ($index) {
      case 1:
        $newDrupalTriggers[LdapUserAttributesInterface::PROVISION_DRUPAL_USER_ON_USER_UPDATE_CREATE] = $trigger ? LdapUserAttributesInterface::PROVISION_DRUPAL_USER_ON_USER_UPDATE_CREATE : '0';
        break;
      case 2:
        $newDrupalTriggers[LdapUserAttributesInterface::PROVISION_DRUPAL_USER_ON_USER_AUTHENTICATION] = $trigger ? LdapUserAttributesInterface::PROVISION_DRUPAL_USER_ON_USER_AUTHENTICATION : '0';
        break;
      case 3:
        $newDrupalTriggers[LdapUserAttributesInterface::PROVISION_DRUPAL_USER_ON_USER_ON_MANUAL_CREATION] = $trigger ? LdapUserAttributesInterface::PROVISION_DRUPAL_USER_ON_USER_ON_MANUAL_CREATION : '0';
        break;
    }
  }
  $config
    ->set('drupalAcctProvisionTriggers', $newDrupalTriggers);
  $existingLdapTriggers = $config
    ->get('ldapEntryProvisionTriggers');
  $newLdapTriggers = [];
  foreach ($existingLdapTriggers as $index => $trigger) {
    switch ($index) {
      case 6:
        $newLdapTriggers[LdapUserAttributesInterface::PROVISION_LDAP_ENTRY_ON_USER_ON_USER_UPDATE_CREATE] = $trigger ? LdapUserAttributesInterface::PROVISION_LDAP_ENTRY_ON_USER_ON_USER_UPDATE_CREATE : '0';
        break;
      case 7:
        $newLdapTriggers[LdapUserAttributesInterface::PROVISION_LDAP_ENTRY_ON_USER_ON_USER_AUTHENTICATION] = $trigger ? LdapUserAttributesInterface::PROVISION_LDAP_ENTRY_ON_USER_ON_USER_AUTHENTICATION : '0';
        break;
      case 8:
        $newLdapTriggers[LdapUserAttributesInterface::PROVISION_LDAP_ENTRY_ON_USER_ON_USER_DELETE] = $trigger ? LdapUserAttributesInterface::PROVISION_LDAP_ENTRY_ON_USER_ON_USER_DELETE : '0';
        break;
    }
  }
  $config
    ->set('ldapEntryProvisionTriggers', $newLdapTriggers);
  $config
    ->save();
}