You are here

public function TBMegaMenuBuilder::findMenuItem in The Better Mega Menu 2.x

Same name and namespace in other branches
  1. 8 src/TBMegaMenuBuilder.php \Drupal\tb_megamenu\TBMegaMenuBuilder::findMenuItem()

Search by menu item.

Parameters

array $tree: The menu tree.

string $plugin_id: The item plugin id.

Return value

\Drupal\Core\Menu\MenuLinkTreeElement The menu link element.

Overrides TBMegaMenuBuilderInterface::findMenuItem

1 call to TBMegaMenuBuilder::findMenuItem()
TBMegaMenuBuilder::getMenuItem in src/TBMegaMenuBuilder.php
Find a menu item.

File

src/TBMegaMenuBuilder.php, line 115

Class

TBMegaMenuBuilder
Defines a TBMegaMenuBuilder.

Namespace

Drupal\tb_megamenu

Code

public function findMenuItem(array $tree, string $plugin_id) {
  foreach ($tree as $menu_plugin_id => $item) {
    if ($menu_plugin_id == $plugin_id) {
      return $item;
    }
    elseif ($result = self::findMenuItem($item->subtree, $plugin_id)) {
      return $result;
    }
  }
  return NULL;
}