BookManager::bookTreeOutput

public BookManager::bookTreeOutput(array $tree)

Returns a rendered menu tree.

The menu item's LI element is given one of the following classes:

  • expanded: The menu item is showing its submenu.
  • collapsed: The menu item has a submenu which is not shown.

Parameters

array $tree: A data structure representing the tree as returned from buildBookOutlineData.

Return value

array A structured array to be rendered by drupal_render().

Overrides BookManagerInterface::bookTreeOutput

See also

\Drupal\Core\Menu\MenuLinkTree::build

File

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

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public function bookTreeOutput(array $tree) {
  $items = $this->buildItems($tree);
 
  $build = [];
 
  if ($items) {
    // Make sure drupal_render() does not re-order the links.
    $build['#sorted'] = TRUE;
    // Get the book id from the last link.
    $item = end($items);
    // Add the theme wrapper for outer markup.
    // Allow menu-specific theme overrides.
    $build['#theme'] = 'book_tree__book_toc_' . $item['original_link']['bid'];
    $build['#items'] = $items;
    // Set cache tag.
    $build['#cache']['tags'][] = 'config:system.book.' . $item['original_link']['bid'];
  }
 
  return $build;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.