public function BookOutlineStorage::updateMovedChildren in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/book/src/BookOutlineStorage.php \Drupal\book\BookOutlineStorage::updateMovedChildren()
Update the book ID of the book link that it's being moved.
Parameters
int $bid: The ID of the book whose children we move.
array $original: The original parent of the book link.
array $expressions: Array of expressions to be added to the query.
int $shift: The difference in depth between the old and the new position of the element being moved.
Return value
mixed The number of rows matched by the update query.
Overrides BookOutlineStorageInterface::updateMovedChildren
File
- core/
modules/ book/ src/ BookOutlineStorage.php, line 160 - Contains \Drupal\book\BookOutlineStorage.
Class
- BookOutlineStorage
- Defines a storage class for books outline.
Namespace
Drupal\bookCode
public function updateMovedChildren($bid, $original, $expressions, $shift) {
$query = $this->connection
->update('book');
$query
->fields(array(
'bid' => $bid,
));
foreach ($expressions as $expression) {
$query
->expression($expression[0], $expression[1], $expression[2]);
}
$query
->expression('depth', 'depth + :depth', array(
':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();
}