<?php

function toc_emr_preprocess_menu__assist_menu(&$vars) {
  // There has to be a better way to know what menu block it's coming from.
  if (isset($vars['menu_block_configuration'])) {
    if ($vars['menu_block_configuration']['label'] == 'Assist menu mobile') {
      $vars['alignment'] = 'left';
    }
  }
}


/**
 * Implements hook_preprocess_menu().
 */
function toc_emr_preprocess_menu__main_header(&$vars) {
  // Embedded Assist menu support.
  if ($assist_menu = _tm_menu_load_menu_build_array('assist-menu')) {
    if (!empty($assist_menu['#items'])) {
      $upper_links = _tm_menu_tpl_process_links($assist_menu['#items'], TRUE);
      if (!empty($upper_links)) {
        $vars['upper_links'] = $upper_links;
        foreach ($vars['upper_links'] as $mid => $link) {
          // As this is assist menu, also use the
          $vars['upper_links'][$mid] = _tm_menu_get_service_updates_link($link);
        }
      }
    }
  }
  if ($mobile_header_menu = _tm_menu_load_menu_build_array('mobile-header-menu')) {
    if (!empty($mobile_header_menu['#items'])) {
      $mobile_header_links = _tm_menu_tpl_process_links($mobile_header_menu['#items'], TRUE);
      if (!empty($mobile_header_links)) {
        $vars['mobile_header_links'] = $mobile_header_links;
      }
    }
  }
}

/**
 * Implements hook_preprocess_menu().
 */
function toc_emr_preprocess_menu__secondary_mobile_menu(&$vars) {
  $vars['attributes']['class'][] = 'pt-3';
}

/**
 * Implements hook_preprocess_menu().
 */
function toc_emr_preprocess_menu__tertiary_mobile_menu(&$vars) {
  $vars['attributes']['class'][] = 'pt-3';
}

/**
 * Implements hook_preprocess_menu().
 */
function toc_emr_preprocess_menu__main_offcanvas(&$vars) {
  $vars['tpl_links'] = _tm_menu_tpl_process_links($vars['items']);
}
