You are here

protected function BookManager::doBookTreeCheckAccess in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/book/src/BookManager.php \Drupal\book\BookManager::doBookTreeCheckAccess()

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

1 call to BookManager::doBookTreeCheckAccess()
BookManager::bookTreeCheckAccess in core/modules/book/src/BookManager.php
Checks access and performs dynamic operations for each link in the tree.

File

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

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