function menu_link_load

Gets a translated, access-checked menu link that is ready for rendering.

This function should never be called from within node_load() or any other function used as a menu object load function since an infinite recursion may occur.

Parameters

$mlid: The mlid of the menu item.

Return value

A menu link, with $item['access'] filled and link translated for rendering.

Related topics

9 calls to menu_link_load()
LinksTest::assertMenuLinkParents in drupal/core/modules/system/lib/Drupal/system/Tests/Menu/LinksTest.php
Assert that at set of links is properly parented.
MenuNodeTest::testMenuNodeFormWidget in drupal/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
Test creating, editing, deleting menu links via node form widget.
MenuTest::getStandardMenuLink in drupal/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
Get standard menu link.
MenuTest::testMenu in drupal/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
Login users, add menus and menu links, and test menu functionality through the admin and user interfaces.
menu_edit_menu_submit in drupal/core/modules/menu/menu.admin.inc
Submit function for adding or editing a custom menu.

... See full list

File

drupal/core/includes/menu.inc, line 2598
API for the Drupal menu system.

Code

function menu_link_load($mlid) {
  if (is_numeric($mlid)) {
    $query = db_select('menu_links', 'ml');
    $query
      ->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
    $query
      ->fields('ml');

    // Weight should be taken from {menu_links}, not {menu_router}.
    $query
      ->addField('ml', 'weight', 'link_weight');
    $query
      ->fields('m');
    $query
      ->condition('ml.mlid', $mlid);
    if ($item = $query
      ->execute()
      ->fetchAssoc()) {
      $item['weight'] = $item['link_weight'];
      _menu_link_translate($item);
      return $item;
    }
  }
  return FALSE;
}