1 admin_bar.inc admin_bar_tree($menu_name)

Build the full administration bar tree from static and expanded dynamic items.

Parameters

$menu_name: The menu name to use as base for the tree.

File

core/modules/admin_bar/admin_bar.inc, line 136
Menu builder functions for Administration bar.

Code

function admin_bar_tree($menu_name) {
  // Get placeholder expansion arguments from hook_admin_bar_map()
  // implementations.
  module_load_include('inc', 'admin_bar', 'admin_bar.map');
  $expand_map = module_invoke_all('admin_bar_map');
  // Allow modules to alter the expansion map.
  backdrop_alter('admin_bar_map', $expand_map);

  $new_map = array();
  foreach ($expand_map as $path => $data) {
    // Convert named placeholders to anonymous placeholders, since the menu
    // system stores paths using anonymous placeholders.
    $replacements = array_fill_keys(array_keys($data['arguments'][0]), '%');
    $data['parent'] = strtr($data['parent'], $replacements);
    $new_map[strtr($path, $replacements)] = $data;
  }
  $expand_map = $new_map;
  unset($new_map);

  // Retrieve dynamic menu link tree for the expansion mappings.
  // @todo Skip entire processing if initial $expand_map is empty and directly
  //   return $tree?
  if (!empty($expand_map)) {
    $tree_dynamic = admin_bar_tree_dynamic($expand_map);
  }
  else {
    $tree_dynamic = array();
  }

  // Merge local tasks with static menu tree.
  $tree = menu_tree_all_data($menu_name);
  admin_bar_merge_tree($tree, $tree_dynamic, array());

  return $tree;
}