You are here

function gin_toolbar_preprocess_menu in Gin Toolbar 8

Implements hook_preprocess_menu().

File

./gin_toolbar.module, line 108
gin_toolbar.module

Code

function gin_toolbar_preprocess_menu(&$variables) {
  if (isset($variables['theme_hook_original']) && $variables['theme_hook_original'] == 'menu__toolbar__admin') {

    // Check if the admin_toolbar module is installed.
    foreach ($variables['items'] as $key => $item) {
      $gin_id = str_replace('.', '-', $key);
      $variables['items'][$key]['gin_id'] = $gin_id;
    }

    // Move config & help menu items to end.
    $to_move = [
      'system.admin_config',
      'help.main',
    ];
    foreach ($to_move as $id) {
      $index = array_search($id, array_keys($variables['items']));
      if (is_numeric($index)) {
        $variables['items'] += array_splice($variables['items'], $index, 1);
      }
    }
  }
}