function BookOutline::nextLink

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

Fetches the book link for the next page of the book.

Parameters

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

Return value

array A fully loaded book link for the page after the one represented in $book_link.

File

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

Class

BookOutline
Provides handling to render the book outline.

Namespace

Drupal\book

Code

public function nextLink(array $book_link) {
    $flat = $this->bookManager
        ->bookTreeGetFlat($book_link);
    reset($flat);
    do {
        $key = key($flat);
        next($flat);
    } while ($key && $key != $book_link['nid']);
    if ($key == $book_link['nid']) {
        $next = current($flat);
        if ($next) {
            $this->bookManager
                ->bookLinkTranslate($next);
        }
        return $next;
    }
}

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