-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrecurring_donation.install
43 lines (37 loc) · 1.06 KB
/
recurring_donation.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* @file
* Contains install and update functions for Recurring PayPal Donations.
*/
use Drupal\recurring_donation\DonationType;
/**
* Converts "Amount settings" config to per donation type settings.
*/
function recurring_donation_update_8001() {
$configHasUpdates = FALSE;
$configFactory = \Drupal::configFactory();
$config = $configFactory->getEditable('recurring_donation.settings');
$settingKeys = [
'options',
'custom',
'custom_label',
'custom_min',
'custom_max',
];
foreach ($settingKeys as $settingKey) {
if (!empty($settingValues = $config->get($settingKey))) {
$configHasUpdates = TRUE;
// Clear old setting.
$config->clear($settingKey);
// Convert setting to all donation types.
foreach (DonationType::getAll() as $donationType) {
$config->set("$donationType.$settingKey", $settingValues);
}
}
}
if ($configHasUpdates) {
$config->save(TRUE);
return t('Amount settings converted.');
}
return t('Amount settings conversion skipped, no updates required.');
}