function BookOutline::childrenLinks

Same name in other branches
  1. 9 core/modules/book/src/BookOutline.php \Drupal\book\BookOutline::childrenLinks()
  2. 10 core/modules/book/src/BookOutline.php \Drupal\book\BookOutline::childrenLinks()
  3. 11.x core/modules/book/src/BookOutline.php \Drupal\book\BookOutline::childrenLinks()

Formats the book links for the child pages of the current page.

Parameters

array $book_link: A fully loaded book link that is part of the book hierarchy.

Return value

array HTML for the links to the child pages of the current page.

File

core/modules/book/src/BookOutline.php, line 108

Class

BookOutline
Provides handling to render the book outline.

Namespace

Drupal\book

Code

public function childrenLinks(array $book_link) {
    $flat = $this->bookManager
        ->bookTreeGetFlat($book_link);
    $children = [];
    if ($book_link['has_children']) {
        // Walk through the array until we find the current page.
        do {
            $link = array_shift($flat);
        } while ($link && $link['nid'] != $book_link['nid']);
        // Continue though the array and collect the links whose parent is this page.
        while (($link = array_shift($flat)) && $link['pid'] == $book_link['nid']) {
            $data['link'] = $link;
            $data['below'] = '';
            $children[] = $data;
        }
    }
    if ($children) {
        return $this->bookManager
            ->bookTreeOutput($children);
    }
    return '';
}

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