W3cubDocs

/Drupal 8

interface MenuLinkTreeInterface

Defines an interface for loading, transforming and rendering menu link trees.

The main purposes of this interface are:

  • Load a list of menu links, given a menu name, using MenuLinkTreeInterface::load(). Loaded menu links are returned as a tree by looking at the links' tree meta-data.
  • Which links are loaded can be specified in the menu link tree parameters that are passed to the load() method. You can build your own set of parameters, or you can start from typical defaults by calling the MenuLinkTreeInterface::getCurrentRouteMenuTreeParameters() method. See \Drupal\Core\Menu\MenuTreeParameters for more on menu tree parameters.
  • Transform a menu link tree, by calling MenuLinkTreeInterface::transform(). Examples include access checking, adding custom classes, extracting a subtree depending on the active trail, etc. Note that translation is not a tree transformation, because menu links themselves are responsible for translation. Transformations are performed by "menu link tree manipulators", which are functions or methods; see \Drupal\menu_link\DefaultMenuTreeManipulators for examples.
  • Create a render array using MenuLinkTreeInterface::build().

Hierarchy

File

core/lib/Drupal/Core/Menu/MenuLinkTreeInterface.php, line 26

Namespace

Drupal\Core\Menu

Members

Name Modifiers Type Description
MenuLinkTreeInterface::build public function Builds a renderable array from a menu tree.
MenuLinkTreeInterface::getCurrentRouteMenuTreeParameters public function Gets the link tree parameters for rendering a specific menu.
MenuLinkTreeInterface::getExpanded public function Finds expanded links in a menu given a set of possible parents.
MenuLinkTreeInterface::getSubtreeHeight public function Finds the height of a subtree rooted by of the given ID.
MenuLinkTreeInterface::load public function Loads a menu tree with a menu link plugin instance at each element.
MenuLinkTreeInterface::maxDepth public function Returns the maximum depth of tree that is supported.
MenuLinkTreeInterface::transform public function Applies menu link tree manipulators to transform the given tree.

© 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!MenuLinkTreeInterface.php/interface/MenuLinkTreeInterface/8.1.x