Migrate contact categories into configuration.
function contact_update_8001() {
$uuid = new Uuid();
$result = db_query('SELECT * FROM {contact}');
foreach ($result as $category) {
// Take over the category's serial ID as new machine name.
$category->id = $category->cid;
// Save default category setting.
if ($category->selected) {
config('contact.settings')
->set('default_category', $category->id)
->save();
}
// Save the config object.
config('contact.category.' . $category->id)
->set('id', $category->id)
->set('uuid', $uuid
->generate())
->set('label', $category->category)
->set('recipients', explode(',', $category->recipients))
->set('reply', $category->reply)
->set('weight', $category->weight)
->set('langcode', Language::LANGCODE_NOT_SPECIFIED)
->save();
}
}