public BookOutlineStorage::getChildRelativeDepth($book_link, $max_depth)
Gets child relative depth.
Parameters
array $book_link: The book link.
int $max_depth: The maximum supported depth of the book tree.
Return value
int The depth of the searched book.
Overrides BookOutlineStorageInterface::getChildRelativeDepth
File
- core/modules/book/src/BookOutlineStorage.php, line 61
Class
- BookOutlineStorage
- Defines a storage class for books outline.
Namespace
Drupal\book
Code
public function getChildRelativeDepth($book_link, $max_depth) { $query = $this->connection->select('book'); $query->addField('book', 'depth'); $query->condition('bid', $book_link['bid']); $query->orderBy('depth', 'DESC'); $query->range(0, 1); $i = 1; $p = 'p1'; while ($i <= $max_depth && $book_link[$p]) { $query->condition($p, $book_link[$p]); $p = 'p' . ++$i; } return $query->execute()->fetchField(); }
Please login to continue.