You are here

public function RenderCheeseburgerMenuBlock::activateMenuItem in Cheeseburger Menu 8.4

If menu is active it activates it.

1 call to RenderCheeseburgerMenuBlock::activateMenuItem()
RenderCheeseburgerMenuBlock::formTree in src/Controller/RenderCheeseburgerMenuBlock.php
Handles forming tree for menus.

File

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

Class

RenderCheeseburgerMenuBlock
Class RenderCheeseburgerMenuBlock.

Namespace

Drupal\cheeseburger_menu\Controller

Code

public function activateMenuItem(&$menu, &$count_active, $pos = FALSE, $url = FALSE) {
  if ($url === FALSE) {
    $url = Url::fromRouteMatch($this->routeMatch)
      ->toString();
  }
  foreach ($menu as $item_key => $menu_item) {
    if ($pos) {
      if (!empty($menu_item['url']) && strpos($url, $menu_item['url']) !== FALSE) {
        if ($url == '/' && $menu_item['url'] == '/' || $menu_item['url'] != '/') {
          $menu[$item_key]['active'] = 'active';
          $count_active++;
        }
      }
      else {
        $menu[$item_key]['active'] = '';
      }
    }
    else {
      if ($menu_item['url'] == $url) {
        $menu[$item_key]['active'] = 'active';
        $count_active++;
      }
      else {
        $menu[$item_key]['active'] = '';
      }
    }
    $this
      ->activateMenuItem($menu[$item_key]['children'], $count_active, $pos, $url);
  }
}