function BookManager::bookSubtreeData

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

File

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

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

public function bookSubtreeData($link) {
    // Generate a cache ID (cid) specific for this $link.
    $cid = "book-links:subtree-data:{$link['nid']}";
    // Get it from cache, if available.
    if ($cache = $this->backendChainedCache
        ->get($cid)) {
        return $cache->data;
    }
    $result = $this->bookOutlineStorage
        ->getBookSubtree($link, static::BOOK_MAX_DEPTH);
    $links = [];
    foreach ($result as $item) {
        $links[] = $item;
    }
    $data['tree'] = $this->buildBookOutlineData($links, [], $link['depth']);
    $data['node_links'] = [];
    $this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']);
    // Check access for the current user to each item in the tree.
    $this->bookTreeCheckAccess($data['tree'], $data['node_links']);
    // Cache subtree data.
    $this->backendChainedCache
        ->set($cid, $data['tree'], Cache::PERMANENT, [
        'bid:' . $link['bid'],
    ]);
    return $data['tree'];
}

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