You are here

function commerce_paypal_update_8103 in Commerce PayPal 8

Move the credit messaging settings to a different config object.

File

./commerce_paypal.install, line 27
Contains install and update functions for Commerce PayPal.

Code

function commerce_paypal_update_8103() {
  $config_factory = \Drupal::configFactory();
  $legacy_config = $config_factory
    ->getEditable('commerce_paypal.settings');
  $client_id = $legacy_config
    ->get('commerce_paypal.credit_messaging_client_id');
  if ($client_id) {
    $config = $config_factory
      ->getEditable('commerce_paypal.credit_messaging_settings');
    $config
      ->set('client_id', $client_id)
      ->set('add_to_cart', $legacy_config
      ->get('commerce_paypal.credit_messaging_add_to_cart'))
      ->save();
    $legacy_config
      ->delete();
  }
}