You are here

protected function MenuItems::checkActiveTrail in Simplify Menu 8.2

Loops through a menu tree array to flag menu items in the active trail.

Parameters

array $menuTree: An array returned from loading a menu tree.

Return value

array The menu items keyed by their plugin IDs. Set to TRUE if in the active trail.

1 call to MenuItems::checkActiveTrail()
MenuItems::setActiveMenuTree in src/MenuItems.php
Loads up the current active menu tree and sets it to a variable.

File

src/MenuItems.php, line 153

Class

MenuItems
Class MenuItems.

Namespace

Drupal\simplify_menu

Code

protected function checkActiveTrail(array $menuTree) : array {
  $active = [];
  foreach ($menuTree as $index => $tree) {
    if ($tree->inActiveTrail) {
      $active[$index] = TRUE;
    }
    else {
      $active[$index] = FALSE;
    }
    if ($tree->hasChildren) {
      $active += $this
        ->checkActiveTrail($tree->subtree);
    }
  }
  return $active;
}