function BookManager::buildBookOutlineData
Same name in other branches
- 8.9.x core/modules/book/src/BookManager.php \Drupal\book\BookManager::buildBookOutlineData()
- 10 core/modules/book/src/BookManager.php \Drupal\book\BookManager::buildBookOutlineData()
- 11.x core/modules/book/src/BookManager.php \Drupal\book\BookManager::buildBookOutlineData()
Sorts and returns the built data representing a book tree.
Parameters
array $links: A flat array of book links that are part of the book. Each array element is an associative array of information about the book link, containing the fields from the {book} table. This array must be ordered depth-first.
array $parents: An array of the node ID values that are in the path from the current page to the root of the book tree.
int $depth: The minimum depth to include in the returned book tree.
Return value
array An array of book links in the form of a tree. Each item in the tree is an associative array containing:
- link: The book link item from $links, with additional element 'in_active_trail' (TRUE if the link ID was in $parents).
- below: An array containing the sub-tree of this item, where each element is a tree item array with 'link' and 'below' elements. This array will be empty if the book link has no items in its sub-tree having a depth greater than or equal to $depth.
2 calls to BookManager::buildBookOutlineData()
- BookManager::bookSubtreeData in core/
modules/ book/ src/ BookManager.php - Gets the data representing a subtree of the book hierarchy.
- BookManager::doBookTreeBuild in core/
modules/ book/ src/ BookManager.php - Builds a book tree.
File
-
core/
modules/ book/ src/ BookManager.php, line 1103
Class
- BookManager
- Defines a book manager.
Namespace
Drupal\bookCode
protected function buildBookOutlineData(array $links, array $parents = [], $depth = 1) {
// Reverse the array so we can use the more efficient array_pop() function.
$links = array_reverse($links);
return $this->buildBookOutlineRecursive($links, $parents, $depth);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.