You are here

protected function BookManager::setParents in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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.

array $parent: The parent values to set.

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

File

core/modules/book/src/BookManager.php, line 891
Contains \Drupal\book\BookManager.

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;
  }
}