You are here

function swiftmailer_update_8102 in Swift Mailer 8.2

Same name and namespace in other branches
  1. 8 swiftmailer.install \swiftmailer_update_8102()

Update username/password credentials configuration.

File

./swiftmailer.install, line 48
Contains install and update functions for SwiftMailer.

Code

function swiftmailer_update_8102() {
  $config = Drupal::configFactory()
    ->getEditable('swiftmailer.transport');
  if (empty($config
    ->get('smtp_credential_provider'))) {
    $config
      ->set('smtp_credential_provider', 'swiftmailer');
    $config
      ->set('smtp_credentials.swiftmailer.username', $config
      ->get('smtp_username'));
    $config
      ->set('smtp_credentials.swiftmailer.password', $config
      ->get('smtp_password'));
    $config
      ->clear('smtp_username');
    $config
      ->clear('smtp_password');
    $config
      ->save();
  }
}