/Drupal 8

class MenuLinkTreeElement

Provides a value object to model an element in a menu link tree.

\Drupal\Core\Menu\MenuLinkTreeElement objects represent a menu link's data. Objects of this class provide complimentary data: the placement in a tree. Therefore, we can summarize this split as follows:

  • Menu link objects contain all information about an individual menu link, plus what their parent is. But they don't know where exactly in a menu link tree they live.
  • Instances of this class are complimentary to those objects, they know:
    • All additional metadata from {menu_tree}, which contains "materialized" metadata about a menu link tree, such as whether a link in the tree has visible children and the depth relative to the root.
    • Plus all additional metadata that's adjusted for the current tree query, such as whether the link is in the active trail, whether the link is accessible for the current user, and the link's children (which are only loaded if the link was marked as "expanded" by the query).


See also



core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php, line 25




Name Modifiers Type Description
MenuLinkTreeElement::$access public property Whether this link is accessible by the current user.
MenuLinkTreeElement::$depth public property The depth of this link relative to the root of the tree.
MenuLinkTreeElement::$hasChildren public property Whether this link has any children at all.
MenuLinkTreeElement::$inActiveTrail public property Whether this link is in the active trail.
MenuLinkTreeElement::$link public property The menu link for this element in a menu link tree.
MenuLinkTreeElement::$options public property Additional options for this link.
MenuLinkTreeElement::$subtree public property The subtree of this element in the menu link tree (this link's children).
MenuLinkTreeElement::count public function Counts all menu links in the current subtree.
MenuLinkTreeElement::__construct public function Constructs a new \Drupal\Core\Menu\MenuLinkTreeElement.

© 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.