protected function DefaultMenuLinkTreeManipulators::collectNodeLinks
protected DefaultMenuLinkTreeManipulators::collectNodeLinks(array &$tree, array &$node_links)
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.
Return value
\Drupal\Core\Menu\MenuLinkTreeElement[] The manipulated menu link tree.
File
- core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php, line 175
Class
- DefaultMenuLinkTreeManipulators
- Provides a couple of menu link tree manipulators.
Namespace
Drupal\Core\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); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!DefaultMenuLinkTreeManipulators.php/function/DefaultMenuLinkTreeManipulators::collectNodeLinks/8.1.x