function salesforce_update_8003 in Salesforce Suite 8.3
Same name and namespace in other branches
- 8.4 salesforce.install \salesforce_update_8003()
- 5.0.x salesforce.install \salesforce_update_8003()
Move API credentials from state to config.
File
- ./
salesforce.install, line 241 - Salesforce install file.
Code
function salesforce_update_8003() {
// Populate config from state.
$config = \Drupal::configFactory()
->getEditable('salesforce.settings');
if ($consumer_key = \Drupal::state()
->get('salesforce.consumer_key', FALSE)) {
$config
->set('consumer_key', $consumer_key);
}
if ($consumer_secret = \Drupal::state()
->get('salesforce.consumer_secret', FALSE)) {
$config
->set('consumer_secret', $consumer_secret);
}
if ($login_url = \Drupal::state()
->get('salesforce.login_url', FALSE)) {
$config
->set('login_url', $login_url);
}
$config
->save();
// Delete deprecated state variables.
$delete = [
'salesforce.consumer_key',
'salesforce.consumer_secret',
'salesforce.login_url',
];
\Drupal::state()
->deleteMultiple($delete);
}