public function MenuLinkTreeHandler::processMenuLinkTree in Menu Item Extras 8.2
Process menu tree items. Add menu item content.
Parameters
array $items: Menu tree items.
string $menu_name: Menu name.
int $menu_level: Menu level number.
bool $show_item_link: Show or not item link.
Return value
array Returns modified menu tree items array.
Overrides MenuLinkTreeHandlerInterface::processMenuLinkTree
File
- src/
Service/ MenuLinkTreeHandler.php, line 141
Class
- MenuLinkTreeHandler
- Class MenuLinkTreeHandler.
Namespace
Drupal\menu_item_extras\ServiceCode
public function processMenuLinkTree(array &$items, $menu_name, $menu_level = -1, $show_item_link = FALSE) {
$menu_level++;
foreach ($items as &$item) {
$content = [];
if (isset($item['original_link'])) {
$content['#item'] = $item;
$content['entity'] = $this
->getMenuLinkItemEntity($item['original_link']);
$content['content'] = $content['entity'] ? $this
->getMenuLinkItemContent($content['entity'], $menu_level, $show_item_link) : NULL;
$content['content']['#cache']['contexts'][] = 'menu_item_extras_link_item_content_active_trails:' . $menu_name . ':' . $item['original_link']
->getDerivativeId();
$content['menu_level'] = $menu_level;
}
// Process subitems.
if (!empty($item['below'])) {
$content['content']['children']['#items'] = $this
->processMenuLinkTree($item['below'], $menu_name, $menu_level, $show_item_link);
$content['content']['children']['#theme'] = 'menu_levels';
$content['content']['children']['#menu_name'] = $menu_name;
$content['content']['children']['#menu_level'] = $menu_level + 1;
}
$item = array_merge($item, $content);
}
return $items;
}