public BookManager::getBookParents(array $item, array $parent = array())
Overrides BookManagerInterface::getBookParents
File
- core/modules/book/src/BookManager.php, line 284
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 26 27 | public function getBookParents( array $item , array $parent = array ()) { $book = array (); if ( $item [ 'pid' ] == 0) { $book [ 'p1' ] = $item [ 'nid' ]; for ( $i = 2; $i <= static ::BOOK_MAX_DEPTH; $i ++) { $parent_property = "p$i" ; $book [ $parent_property ] = 0; } $book [ 'depth' ] = 1; } else { $i = 1; $book [ 'depth' ] = $parent [ 'depth' ] + 1; while ( $i < $book [ 'depth' ]) { $p = 'p' . $i ++; $book [ $p ] = $parent [ $p ]; } $p = 'p' . $i ++; // The parent (p1 - p9) corresponding to the depth always equals the nid. $book [ $p ] = $item [ 'nid' ]; while ( $i <= static ::BOOK_MAX_DEPTH) { $p = 'p' . $i ++; $book [ $p ] = 0; } } return $book ; } |
Please login to continue.