You are here

public function RenderCheeseburgerMenuBlock::formTree in Cheeseburger Menu 8.4

Handles forming tree for menus.

1 call to RenderCheeseburgerMenuBlock::formTree()
RenderCheeseburgerMenuBlock::renderTree in src/Controller/RenderCheeseburgerMenuBlock.php
Render given tree.

File

src/Controller/RenderCheeseburgerMenuBlock.php, line 260
Controller used for rendering block.

Class

RenderCheeseburgerMenuBlock
Class RenderCheeseburgerMenuBlock.

Namespace

Drupal\cheeseburger_menu\Controller

Code

public function formTree(&$tree, $current_url = FALSE, $active_state = TRUE) {
  $count_active = 0;
  if ($active_state) {
    foreach ($tree as $tree_key => $menu) {
      if (!array_key_exists('tree', $menu)) {
        continue;
      }
      $this
        ->activateMenuItem($tree[$tree_key]['tree'], $count_active, FALSE, $current_url);
    }
    if ($count_active === 0) {
      foreach ($tree as $tree_key => $menu) {
        if (!array_key_exists('tree', $menu)) {
          continue;
        }
        $this
          ->activateMenuItem($tree[$tree_key]['tree'], $count_active, TRUE, $current_url);
      }
    }
  }
  $this
    ->sortMenus($tree);
}