bookSubtreeData example


  public function bookExportHtml(NodeInterface $node) {
    if (!isset($node->book)) {
      throw new \Exception();
    }

    $tree = $this->bookManager->bookSubtreeData($node->book);
    $contents = $this->exportTraverse($tree[$this, 'bookNodeExport']);
    $node = $this->entityRepository->getTranslationFromContext($node);
    return [
      '#theme' => 'book_export_html',
      '#title' => $node->label(),
      '#contents' => $contents,
      '#depth' => $node->book['depth'],
      '#cache' => [
        'tags' => $node->getEntityType()->getListCacheTags(),
      ],
    ];
  }
do {
      $prev = $curr;
      $key = key($flat);
      $curr = current($flat);
      next($flat);
    } while ($key && $key != $book_link['nid']);

    if ($key == $book_link['nid']) {
      // The previous page in the book may be a child of the previous visible link.       if ($prev['depth'] == $book_link['depth']) {
        // The subtree will have only one link at the top level - get its data.         $tree = $this->bookManager->bookSubtreeData($prev);
        $data = array_shift($tree);
        // The link of interest is the last child - iterate to find the deepest one.         while ($data['below']) {
          $data = end($data['below']);
        }
        $this->bookManager->bookLinkTranslate($data['link']);
        return $data['link'];
      }
      else {
        $this->bookManager->bookLinkTranslate($prev);
        return $prev;
      }
'hidden' => TRUE,
          'limit' => BookManager::BOOK_MAX_DEPTH - 2,
        ],
        [
          'action' => 'order',
          'relationship' => 'sibling',
          'group' => 'book-weight',
        ],
      ],
    ];

    $tree = $this->bookManager->bookSubtreeData($node->book);
    // Do not include the book item itself.     $tree = array_shift($tree);
    if ($tree['below']) {
      $hash = Crypt::hashBase64(serialize($tree['below']));
      // Store the hash value as a hidden form element so that we can detect       // if another user changed the book hierarchy.       $form['tree_hash'] = [
        '#type' => 'hidden',
        '#default_value' => $hash,
      ];
      $form['tree_current_hash'] = [
        
Home | Imprint | This part of the site doesn't use cookies.