public function BookOutlineStorage::getBookMenuTree in Drupal 10
Same name and namespace in other branches
- 8 core/modules/book/src/BookOutlineStorage.php \Drupal\book\BookOutlineStorage::getBookMenuTree()
- 9 core/modules/book/src/BookOutlineStorage.php \Drupal\book\BookOutlineStorage::getBookMenuTree()
File
- core/
modules/ book/ src/ BookOutlineStorage.php, line 99
Class
- BookOutlineStorage
- Defines a storage class for books outline.
Namespace
Drupal\bookCode
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();
}