protected function AnonymousMenuLinkTreeManipulator::collectNodeLinks in footermap: a footer site map 8
Collects the node links in the menu tree.
Parameters
\Drupal\Core\Menu\MenuLinkTreeElement[] $tree: The menu link tree to manipulate.
array $node_links: Stores references to menu link elements to effectively set access.
1 call to AnonymousMenuLinkTreeManipulator::collectNodeLinks()
- AnonymousMenuLinkTreeManipulator::checkNodeAccess in src/
Menu/ AnonymousMenuLinkTreeManipulator.php - Performs access checking for nodes in an optimized way.
File
- src/
Menu/ AnonymousMenuLinkTreeManipulator.php, line 183
Class
- AnonymousMenuLinkTreeManipulator
- Provides an anonymous-based menu link tree manipulator.
Namespace
Drupal\footermap\MenuCode
protected function collectNodeLinks(array &$tree, array &$node_links) {
foreach ($tree as $key => &$element) {
if ($element->link
->getRouteName() == 'entity.node.canonical') {
$nid = $element->link
->getRouteParameters()['node'];
$node_links[$nid][$key] = $element;
// Deny access by default. checkNodeAccess() will re-add it.
$element->access = AccessResult::neutral();
}
if ($element->hasChildren) {
$this
->collectNodeLinks($element->subtree, $node_links);
}
}
}