function user_expire_update_8002 in User Expire 8
Convert user_expire_roles to config.
File
- ./
user_expire.install, line 53 - Install and update functions for the User expire module.
Code
function user_expire_update_8002() {
$rules = \Drupal::database()
->select('user_expire_roles', 'uer')
->fields('uer', [
'rid',
'inactivity_period',
])
->execute()
->fetchAllAssoc('rid');
// Convert structure.
foreach ($rules as &$rule) {
$rule = (int) $rule->inactivity_period;
}
$config_factory = \Drupal::configFactory();
$config = $config_factory
->getEditable('user_expire.settings');
$config
->set('user_expire_roles', $rules);
$config
->save();
\Drupal::database()
->schema()
->dropTable('user_expire_roles');
}