public BookOutlineStorage::getBookMenuTree($bid, $parameters, $min_depth, $max_depth)
Builds tree data used for the menu tree.
Parameters
int $bid: The ID of the book that we are building the tree for.
array $parameters: An associative array of build parameters. For info about individual parameters see BookManager::bookTreeBuild().
int $min_depth: The minimum depth of book links in the resulting tree.
int $max_depth: The maximum supported depth of the book tree.
Return value
array Array of loaded book links.
Overrides BookOutlineStorageInterface::getBookMenuTree
File
- core/modules/book/src/BookOutlineStorage.php, line 99
Class
- BookOutlineStorage
- Defines a storage class for books outline.
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 | public function getBookMenuTree( $bid , $parameters , $min_depth , $max_depth ) { $query = $this ->connection->select( 'book' ); $query ->fields( 'book' ); for ( $i = 1; $i <= $max_depth ; $i ++) { $query ->orderBy( 'p' . $i , 'ASC' ); } $query ->condition( 'bid' , $bid ); if (! empty ( $parameters [ 'expanded' ])) { $query ->condition( 'pid' , $parameters [ 'expanded' ], 'IN' ); } if ( $min_depth != 1) { $query ->condition( 'depth' , $min_depth , '>=' ); } if (isset( $parameters [ 'max_depth' ])) { $query ->condition( 'depth' , $parameters [ 'max_depth' ], '<=' ); } // Add custom query conditions, if any were passed. if (isset( $parameters [ 'conditions' ])) { foreach ( $parameters [ 'conditions' ] as $column => $value ) { $query ->condition( $column , $value ); } } return $query ->execute(); } |
Please login to continue.