protected BookManager::moveChildren(array $link, array $original)
Moves children from the original parent to the updated link.
Parameters
array $link: The link being saved.
array $original: The original parent of $link.
File
- core/modules/book/src/BookManager.php, line 826
Class
- BookManager
- Defines a book manager.
Namespace
Drupal\book
Code
protected function moveChildren(array $link, array $original) { $p = 'p1'; $expressions = array(); for ($i = 1; $i <= $link['depth']; $p = 'p' . ++$i) { $expressions[] = array($p, ":p_$i", array(":p_$i" => $link[$p])); } $j = $original['depth'] + 1; while ($i <= static::BOOK_MAX_DEPTH && $j <= static::BOOK_MAX_DEPTH) { $expressions[] = array('p' . $i++, 'p' . $j++, array()); } while ($i <= static::BOOK_MAX_DEPTH) { $expressions[] = array('p' . $i++, 0, array()); } $shift = $link['depth'] - $original['depth']; if ($shift > 0) { // The order of expressions must be reversed so the new values don't // overwrite the old ones before they can be used because "Single-table // UPDATE assignments are generally evaluated from left to right" // @see http://dev.mysql.com/doc/refman/5.0/en/update.html $expressions = array_reverse($expressions); } $this->bookOutlineStorage->updateMovedChildren($link['bid'], $original, $expressions, $shift); }
Please login to continue.