class SimpleMobileMenuMenuLinkTree in Simple Mobile Menu 8.2
Same name and namespace in other branches
- 8 src/Menu/SimpleMobileMenuMenuLinkTree.php \Drupal\simple_mobile_menu\Menu\SimpleMobileMenuMenuLinkTree
Extends MenuLinkTree to add specific theme suggestions for the toolbar.
Hierarchy
- class \Drupal\Core\Menu\MenuLinkTree implements MenuLinkTreeInterface
- class \Drupal\simple_mobile_menu\Menu\SimpleMobileMenuMenuLinkTree
Expanded class hierarchy of SimpleMobileMenuMenuLinkTree
1 string reference to 'SimpleMobileMenuMenuLinkTree'
1 service uses SimpleMobileMenuMenuLinkTree
File
- src/
Menu/ SimpleMobileMenuMenuLinkTree.php, line 10
Namespace
Drupal\simple_mobile_menu\MenuView source
class SimpleMobileMenuMenuLinkTree extends MenuLinkTree {
/**
* {@inheritdoc}
*/
public function build(array $tree, $level = 0) {
if ($level == 0) {
if (!$tree) {
return [];
}
$build = parent::build($tree, $level);
/** @var \Drupal\Core\Menu\MenuLinkInterface $link */
$first_link = reset($tree)->link;
// Get the menu name of the first link.
$menu_name = $first_link
->getMenuName();
// Add a more specific theme suggestion to differentiate this rendered
// menu from others.
$build['#menu_name'] = $menu_name;
$build['#theme'] = 'menu__simple_mobile_menu__' . strtr($menu_name, '-', '_');
return $build;
}
else {
return parent::build($tree, $level);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MenuLinkTree:: |
protected | property | The controller resolver. | |
MenuLinkTree:: |
protected | property | The active menu trail service. | |
MenuLinkTree:: |
protected | property | The menu link plugin manager. | |
MenuLinkTree:: |
protected | property | The route provider to load routes by name. | |
MenuLinkTree:: |
protected | property | The menu link tree storage. | |
MenuLinkTree:: |
protected | function | Builds the #items property for a menu tree's renderable array. | |
MenuLinkTree:: |
protected | function | Returns a tree containing of MenuLinkTreeElement based upon tree data. | |
MenuLinkTree:: |
public | function |
Gets the link tree parameters for rendering a specific menu. Overrides MenuLinkTreeInterface:: |
|
MenuLinkTree:: |
public | function |
Finds expanded links in a menu given a set of possible parents. Overrides MenuLinkTreeInterface:: |
|
MenuLinkTree:: |
public | function |
Finds the height of a subtree rooted by of the given ID. Overrides MenuLinkTreeInterface:: |
|
MenuLinkTree:: |
public | function |
Loads a menu tree with a menu link plugin instance at each element. Overrides MenuLinkTreeInterface:: |
|
MenuLinkTree:: |
public | function |
Returns the maximum depth of tree that is supported. Overrides MenuLinkTreeInterface:: |
|
MenuLinkTree:: |
public | function |
Applies menu link tree manipulators to transform the given tree. Overrides MenuLinkTreeInterface:: |
|
MenuLinkTree:: |
public | function | Constructs a \Drupal\Core\Menu\MenuLinkTree object. | |
SimpleMobileMenuMenuLinkTree:: |
public | function |
Builds a renderable array from a menu tree. Overrides MenuLinkTree:: |