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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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" $expressions = array_reverse ( $expressions ); } $this ->bookOutlineStorage->updateMovedChildren( $link [ 'bid' ], $original , $expressions , $shift ); } |
Please login to continue.