1 book.module book_node_type_update($type)

Implements hook_node_type_update().

Updates the Book module's persistent variables if the machine-readable name of a node type is changed.

File

core/modules/book/book.module, line 1157
Allows users to create and organize related content in an outline.

Code

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('book_allowed_types');
    $key = array_search($type->old_type, $allowed_types);

    if ($key !== FALSE) {
      $allowed_types[$type->type] = $allowed_types[$key] ? $type->type : 0;
      unset($allowed_types[$key]);
      $config->set('book_allowed_types', $allowed_types);
    }

    // Update the setting for the "Add child page" link.
    if ($config->get('book_child_type') == $type->old_type) {
      $config->set('book_child_type', $type->type);
    }
    $config->save();
  }
}