You are here

function template_preprocess_we_megamenu_subul in Drupal Mega Menu 8

Same name and namespace in other branches
  1. 8.x we_megamenu.module \template_preprocess_we_megamenu_subul()

Prepare variables for we_megamenu_subul.

Parameters

array $vars: Variables are declared in theme.

File

./we_megamenu.module, line 563
Drupal 8 Mega Menu Module.

Code

function template_preprocess_we_megamenu_subul(array &$vars) {
  if ($vars['item_config']) {
    foreach ($vars['items'] as $key_li => $li) {
      $derivativeId = $li['derivativeId'];
      foreach ($vars['item_config'] as $key_item => $item) {
        if (isset($item->mlid)) {
          if ($item->mlid == $derivativeId) {
            $vars['lis'][] = [
              '#theme' => [
                'we_megamenu_li',
              ],
              '#title' => $li['title'],
              '#item' => $li,
              '#subtree' => $li['subtree'],
              '#section' => $vars['section'],
              '#block_theme' => $vars['block_theme'],
              '#menu_name' => $vars['menu_name'],
              '#trail' => $vars['trail'],
            ];
          }
        }
      }
    }
  }
  else {
    foreach ($vars['items'] as $key_li => $li) {
      $vars['lis'][] = [
        '#theme' => [
          'we_megamenu_li',
        ],
        '#title' => $li['title'],
        '#item' => $li,
        '#subtree' => $li['subtree'],
        '#section' => $vars['section'],
        '#block_theme' => $vars['block_theme'],
        '#menu_name' => $vars['menu_name'],
        '#trail' => $vars['trail'],
      ];
    }
  }
}