Implements hook_node_type_update().
Updates book.settings configuration object if the machine-readable name of a node type is changed.
function book_node_type_update($type) {
if (!empty($type->old_type) && $type->old_type != $type->type) {
$config = config('book.settings');
// Update the list of node types that are allowed to be added to books.
$allowed_types = $config
->get('allowed_types');
$old_key = array_search($type->old_type, $allowed_types);
if ($old_key !== FALSE) {
// Replace the old machine-readable name with the new machine-readable
// name.
$allowed_types[$old_key] = $type->type;
// Ensure that the allowed_types array is sorted consistently.
// @see book_admin_settings_submit()
sort($allowed_types);
$config
->set('allowed_types', $allowed_types);
}
// Update the setting for the "Add child page" link.
if ($config
->get('child_type') == $type->old_type) {
$config
->set('child_type', $type->type);
}
$config
->save();
}
}