function BookManager::bookTreeOutput

Same name in this branch
  1. 11.x core/modules/book/src/ProxyClass/BookManager.php \Drupal\book\ProxyClass\BookManager::bookTreeOutput()
Same name in other branches
  1. 9 core/modules/book/src/BookManager.php \Drupal\book\BookManager::bookTreeOutput()
  2. 8.9.x core/modules/book/src/BookManager.php \Drupal\book\BookManager::bookTreeOutput()
  3. 10 core/modules/book/src/ProxyClass/BookManager.php \Drupal\book\ProxyClass\BookManager::bookTreeOutput()
  4. 10 core/modules/book/src/BookManager.php \Drupal\book\BookManager::bookTreeOutput()

File

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

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

public function bookTreeOutput(array $tree) {
    $items = $this->buildItems($tree);
    $build = [];
    if ($items) {
        // Make sure Drupal\Core\Render\Element::children() 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;
}

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