You are here

public function BookOutlineStorage::insert in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/book/src/BookOutlineStorage.php \Drupal\book\BookOutlineStorage::insert()

Inserts a book link.

Parameters

array $link: The link array to be inserted in the database.

array $parents: The array of parent ids for the link to be inserted.

Return value

mixed The last insert ID of the query, if one exists.

Overrides BookOutlineStorageInterface::insert

File

core/modules/book/src/BookOutlineStorage.php, line 128

Class

BookOutlineStorage
Defines a storage class for books outline.

Namespace

Drupal\book

Code

public function insert($link, $parents) {
  return $this->connection
    ->insert('book')
    ->fields([
    'nid' => $link['nid'],
    'bid' => $link['bid'],
    'pid' => $link['pid'],
    'weight' => $link['weight'],
  ] + $parents)
    ->execute();
}