protected function BookManager::doBookTreeCheckAccess in Drupal 10
Same name and namespace in other branches
- 8 core/modules/book/src/BookManager.php \Drupal\book\BookManager::doBookTreeCheckAccess()
- 9 core/modules/book/src/BookManager.php \Drupal\book\BookManager::doBookTreeCheckAccess()
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 1023
Class
- BookManager
- Defines a book manager.
Namespace
Drupal\bookCode
protected function doBookTreeCheckAccess(&$tree) {
$new_tree = [];
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;
}