You are here

public function BookOutlineStorage::updateMovedChildren in Drupal 10

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

File

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

Class

BookOutlineStorage
Defines a storage class for books outline.

Namespace

Drupal\book

Code

public function updateMovedChildren($bid, $original, $expressions, $shift) {
  $query = $this->connection
    ->update('book');
  $query
    ->fields([
    'bid' => $bid,
  ]);
  foreach ($expressions as $expression) {
    $query
      ->expression($expression[0], $expression[1], $expression[2]);
  }
  $query
    ->expression('depth', '[depth] + :depth', [
    ':depth' => $shift,
  ]);
  $query
    ->condition('bid', $original['bid']);
  $p = 'p1';
  for ($i = 1; !empty($original[$p]); $p = 'p' . ++$i) {
    $query
      ->condition($p, $original[$p]);
  }
  return $query
    ->execute();
}