You are here

function google_analytics_reports_api_update_8001 in Google Analytics Reports 8.3

Move the access_token, expires_at and refresh_token from config to state.

File

google_analytics_reports_api/google_analytics_reports_api.install, line 36
Installation file for Google Analytics Reports API module.

Code

function google_analytics_reports_api_update_8001() {
  $config = \Drupal::configFactory()
    ->getEditable('google_analytics_reports_api.settings');
  $state = \Drupal::state();
  $access_token = $config
    ->get('access_token');
  if ($access_token) {
    $state
      ->set('google_analytics_reports_api.access_token', $access_token);
    $config
      ->clear('access_token');
  }
  $expires_at = $config
    ->get('expires_at');
  if ($expires_at) {
    $state
      ->set('google_analytics_reports_api.expires_at', $expires_at);
    $config
      ->clear('expires_at');
  }
  $refresh_token = $config
    ->get('refresh_token');
  if ($refresh_token) {
    $state
      ->set('google_analytics_reports_api.refresh_token', $refresh_token);
    $config
      ->clear('refresh_token');
  }
  $config
    ->save();
}