You are here

function ldap_authentication_update_8305 in Lightweight Directory Access Protocol (LDAP) 8.4

Update configuration to new syntax.

File

ldap_authentication/ldap_authentication.install, line 68

Code

function ldap_authentication_update_8305() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('ldap_authentication.settings');
  switch ($config
    ->get('passwordOption')) {
    case 2:
      $config
        ->set('passwordOption', 'disable');
      break;
    case 3:
      $config
        ->set('passwordOption', 'hide');
      break;
    case 4:
      $config
        ->set('passwordOption', 'allow');
      break;
  }
  switch ($config
    ->get('emailOption')) {
    case 2:
      $config
        ->set('emailOption', 'remove');
      break;
    case 3:
      $config
        ->set('emailOption', 'disable');
      break;
    case 4:
      $config
        ->set('emailOption', 'allow');
      break;
  }
  switch ($config
    ->get('emailUpdate')) {
    case 1:
      $config
        ->set('emailUpdate', 'update_notify');
      break;
    case 2:
      $config
        ->set('emailUpdate', 'update');
      break;
    case 3:
      $config
        ->set('emailUpdate', 'no_update');
      break;
  }
  switch ($config
    ->get('authenticationMode')) {
    case 1:
      $config
        ->set('authenticationMode', 'mixed');
      break;
    case 2:
      $config
        ->set('authenticationMode', 'exclusive');
      break;
  }
  $config
    ->save();
}