function BookManager::updateParent

Same name in other branches
  1. 9 core/modules/book/src/BookManager.php \Drupal\book\BookManager::updateParent()
  2. 8.9.x core/modules/book/src/BookManager.php \Drupal\book\BookManager::updateParent()
  3. 11.x core/modules/book/src/BookManager.php \Drupal\book\BookManager::updateParent()

Sets the has_children flag of the parent of the node.

This method is mostly called when a book link is moved/created etc. So we want to update the has_children flag of the new parent book link.

Parameters

array $link: The book link, data reflecting its new position, whose new parent we want to update.

Return value

bool TRUE if the update was successful (either there is no parent to update, or the parent was updated successfully), FALSE on failure.

1 call to BookManager::updateParent()
BookManager::saveBookLink in core/modules/book/src/BookManager.php

File

core/modules/book/src/BookManager.php, line 937

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

protected function updateParent(array $link) {
    if ($link['pid'] == 0) {
        // Nothing to update.
        return TRUE;
    }
    return $this->bookOutlineStorage
        ->update($link['pid'], [
        'has_children' => 1,
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.