1 layout.module layout_menu_item_load_multiple($menu_item_names = NULL)

Load menu items by name.

Parameters

array $menu_item_names: An array of menu item names, if left empty, all Layout menu items will be returned.

Return value

array: An array of loaded LayoutMenuItem instances, keyed by the layout menu item path.

File

core/modules/layout/layout.module, line 1339
The Layout module creates pages and wraps existing pages in layouts.

Code

function layout_menu_item_load_multiple($menu_item_names = NULL) {
  $loaded_menu_items = &backdrop_static(__FUNCTION__, array());

  $menu_items_to_load = array();
  foreach ($menu_item_names as $menu_item_name) {
    if (!isset($loaded_menu_items[$menu_item_name])) {
      $menu_items_to_load[] = $menu_item_name;
    }
  }

  if ($menu_items_to_load) {
    $configs = layout_get_all_configs('menu_item');
    foreach ($menu_items_to_load as $menu_item_name) {
      if (isset($configs[$menu_item_name])) {
        $loaded_menu_items[$menu_item_name] = new LayoutMenuItem($configs[$menu_item_name]);
      }
    }
  }

  // Return the requested menu items.
  $menu_items = array();
  foreach ($menu_item_names as $menu_item_name) {
    if (isset($loaded_menu_items[$menu_item_name])) {
      $path = $loaded_menu_items[$menu_item_name]->path;
      $menu_items[$path] = $loaded_menu_items[$menu_item_name];
    }
  }

  return $menu_items;
}