function BookManager::getActiveTrailIds

Same name in this branch
  1. 10 core/modules/book/src/ProxyClass/BookManager.php \Drupal\book\ProxyClass\BookManager::getActiveTrailIds()
Same name and namespace in other branches
  1. 9 core/modules/book/src/BookManager.php \Drupal\book\BookManager::getActiveTrailIds()
  2. 8.9.x core/modules/book/src/BookManager.php \Drupal\book\BookManager::getActiveTrailIds()
  3. 11.x core/modules/book/src/ProxyClass/BookManager.php \Drupal\book\ProxyClass\BookManager::getActiveTrailIds()
  4. 11.x core/modules/book/src/BookManager.php \Drupal\book\BookManager::getActiveTrailIds()

Gets the active trail IDs for the specified book at the provided path.

Parameters

string $bid: The Book ID to find links for.

array $link: A fully loaded menu link.

Return value

array An array containing the active trail: a list of menu link IDs.

Overrides BookManagerInterface::getActiveTrailIds

1 call to BookManager::getActiveTrailIds()
BookManager::bookTreeAllData in core/modules/book/src/BookManager.php
Gets the data structure representing a named menu tree.

File

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

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

public function getActiveTrailIds($bid, $link) {
  // The tree is for a single item, so we need to match the values in its
  // p columns and 0 (the top level) with the plid values of other links.
  $active_trail = [
    0,
  ];
  for ($i = 1; $i < static::BOOK_MAX_DEPTH; $i++) {
    if (!empty($link["p{$i}"])) {
      $active_trail[] = $link["p{$i}"];
    }
  }
  return $active_trail;
}

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