BookManager::doBookTreeCheckAccess

protected BookManager::doBookTreeCheckAccess(&$tree)

Sorts the menu tree and recursively checks access for each item.

Parameters

array $tree: The book tree to operate on.

File

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

Class

BookManager
Defines a book manager.

Namespace

Drupal\book

Code

protected function doBookTreeCheckAccess(&$tree) {
  $new_tree = array();
  foreach ($tree as $key => $v) {
    $item = &$tree[$key]['link'];
    $this->bookLinkTranslate($item);
    if ($item['access']) {
      if ($tree[$key]['below']) {
        $this->doBookTreeCheckAccess($tree[$key]['below']);
      }
      // The weights are made a uniform 5 digits by adding 50000 as an offset.
      // After calling $this->bookLinkTranslate(), $item['title'] has the
      // translated title. Adding the nid to the end of the index insures that
      // it is unique.
      $new_tree[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['nid']] = $tree[$key];
    }
  }
  // Sort siblings in the tree based on the weights and localized titles.
  ksort($new_tree);
  $tree = $new_tree;
}
doc_Drupal
2016-10-29 08:48:10
Comments
Leave a Comment

Please login to continue.