function BookManager::setParents

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

Sets the p1 through p9 properties for a book link being saved.

Parameters

array $link: The book link to update, passed by reference.

array $parent: The parent values to set.

1 call to BookManager::setParents()
BookManager::saveBookLink in core/modules/book/src/BookManager.php
Saves a link for a single book entry to the book.

File

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

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

protected function setParents(array &$link, array $parent) {
    $i = 1;
    while ($i < $link['depth']) {
        $p = 'p' . $i++;
        $link[$p] = $parent[$p];
    }
    $p = 'p' . $i++;
    // The parent (p1 - p9) corresponding to the depth always equals the nid.
    $link[$p] = $link['nid'];
    while ($i <= static::BOOK_MAX_DEPTH) {
        $p = 'p' . $i++;
        $link[$p] = 0;
    }
}

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