public BookManager::updateOutline(NodeInterface $node)
Handles additions and updates to the book outline.
This common helper function performs all additions and updates to the book outline through node addition, node editing, node deletion, or the outline tab.
Parameters
\Drupal\node\NodeInterface $node: The node that is being saved, added, deleted, or moved.
Return value
bool TRUE if the book link was saved; FALSE otherwise.
Overrides BookManagerInterface::updateOutline
File
- core/modules/book/src/BookManager.php, line 247
Class
- BookManager
- Defines a book manager.
Namespace
Drupal\book
Code
public function updateOutline(NodeInterface $node) { if (empty($node->book['bid'])) { return FALSE; } if (!empty($node->book['bid'])) { if ($node->book['bid'] == 'new') { // New nodes that are their own book. $node->book['bid'] = $node->id(); } elseif (!isset($node->book['original_bid'])) { $node->book['original_bid'] = $node->book['bid']; } } // Ensure we create a new book link if either the node itself is new, or the // bid was selected the first time, so that the original_bid is still empty. $new = empty($node->book['nid']) || empty($node->book['original_bid']); $node->book['nid'] = $node->id(); // Create a new book from a node. if ($node->book['bid'] == $node->id()) { $node->book['pid'] = 0; } elseif ($node->book['pid'] < 0) { // -1 is the default value in BookManager::addParentSelectFormElements(). // The node save should have set the bid equal to the node ID, but // handle it here if it did not. $node->book['pid'] = $node->book['bid']; } return $this->saveBookLink($node->book, $new); }
Please login to continue.