function salesforce_update_8006 in Salesforce Suite 8.4
Same name and namespace in other branches
- 8.3 salesforce.install \salesforce_update_8006()
- 5.0.x salesforce.install \salesforce_update_8006()
Convert legacy token to new auth plugin config.
File
- ./
salesforce.install, line 318 - Salesforce install file.
Code
function salesforce_update_8006() {
$oauth = SalesforceAuthConfig::load('oauth_default');
if (!$oauth) {
return "Auth config missing. Refused to update legacy token.";
}
try {
\Drupal::service('salesforce.auth_token_storage')
->retrieveAccessToken($oauth
->id());
return "Token exists. Refused to update.";
} catch (TokenNotFoundException $e) {
\Drupal::service('salesforce.auth_token_storage')
->storeAccessToken('oauth_default', new SalesforceToken(\Drupal::state()
->get('salesforce.access_token'), \Drupal::state()
->get('salesforce.refresh_token')));
return "Updated legacy token to new plugin config.";
}
}