function BookOutlineStorage::getBookMenuTree

File

core/modules/book/src/BookOutlineStorage.php, line 99

Class

BookOutlineStorage
Defines a storage class for books outline.

Namespace

Drupal\book

Code

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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.