You are here

function acquia_connector_update_8007 in Acquia Connector 8

Move subscription data to state.

File

./acquia_connector.install, line 301
Install, update, and uninstall functions for the Acquia Connector module.

Code

function acquia_connector_update_8007() {
  $config = \Drupal::configFactory()
    ->getEditable('acquia_connector.settings');

  // Handle subscription data first.
  $subscription_data = $config
    ->get('subscription_data');
  if ($subscription_data) {
    \Drupal::state()
      ->set('acquia_subscription_data', $subscription_data);
    $config
      ->clear('subscription_data')
      ->save();
  }

  // Now handle SPI vars.
  $spi_moved_keys = [
    'def_vars',
    'def_waived_vars',
    'def_timestamp',
    'new_optional_data',
  ];
  foreach ($spi_moved_keys as $key) {
    $data = $config
      ->get("spi.{$key}");
    if ($data) {
      \Drupal::state()
        ->set("acquia_spi_data.{$key}", $data);
      $config
        ->clear("spi.{$key}")
        ->save();
    }
  }
}