BookManager::buildBookOutlineData

protected BookManager::buildBookOutlineData(array $links, array $parents = array(), $depth = 1)

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.

File

core/modules/book/src/BookManager.php, line 1024

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

protected function buildBookOutlineData(array $links, array $parents = array(), $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);
}
doc_Drupal
2016-10-29 08:48:09
Comments
Leave a Comment

Please login to continue.