book_node_type_update(NodeTypeInterface $type)
Implements hook_ENTITY_TYPE_update() for node_type entities.
Updates book.settings configuration object if the machine-readable name of a node type is changed.
File
- core/modules/book/book.module, line 519
- Allows users to create and organize related content in an outline.
Code
function book_node_type_update(NodeTypeInterface $type) { if ($type->getOriginalId() != $type->id()) { $config = \Drupal::configFactory()->getEditable('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->getOriginalId(), $allowed_types); if ($old_key !== FALSE) { $allowed_types[$old_key] = $type->id(); // Ensure that the allowed_types array is sorted consistently. // @see BookSettingsForm::submitForm() sort($allowed_types); $config->set('allowed_types', $allowed_types); } // Update the setting for the "Add child page" link. if ($config->get('child_type') == $type->getOriginalId()) { $config->set('child_type', $type->id()); } $config->save(); } }
Please login to continue.