function spambot_update_8003 in Spambot 8
Set default value for new config settings.
File
- ./
spambot.install, line 109 - Install and update hooks for Spambot module.
Code
function spambot_update_8003() {
$variables = [
'spambot_cron_user_limit' => 0,
'spambot_spam_account_action' => 0,
'spambot_criteria_email' => 1,
'spambot_criteria_username' => 0,
'spambot_criteria_ip' => 20,
'spambot_blacklisted_delay' => 20,
'spambot_blocked_message_email' => 'Your email address or username or IP address is blacklisted.',
'spambot_blocked_message_username' => 'Your email address or username or IP address is blacklisted.',
'spambot_blocked_message_ip' => 'Your email address or username or IP address is blacklisted.',
];
/* @var \Drupal\Core\Config\Config $configuration */
$configuration = \Drupal::service('config.factory')
->getEditable('spambot.settings');
$is_updated = FALSE;
foreach ($variables as $key => $default) {
$conf = $configuration
->get($key);
if (!isset($conf)) {
$configuration
->set($key, $default);
$is_updated = TRUE;
}
}
// Save new config.
if ($is_updated) {
$configuration
->save();
}
}