_menu_find_router_path

Definition

_menu_find_router_path($menu, $link_path)
drupal/includes/menu.inc, line 2221

Description

Find the router path which will serve this path.

Parameters

$menu The full built menu.

$link_path The path for we are looking up its router path.

Return value

A path from $menu keys or empty if $link_path points to a nonexisting place.

Related topics

Namesort iconDescription
Menu systemDefine the navigation menus, and route page requests to code based on URLs.

Code

function _menu_find_router_path($menu, $link_path) {
  $parts = explode('/', $link_path, MENU_MAX_PARTS);
  $router_path = $link_path;
  if (!isset($menu[$router_path])) {
    $ancestors = menu_get_ancestors($parts);
    $ancestors[] = '';
    foreach ($ancestors as $key => $router_path) {
      if (isset($menu[$router_path])) {
        break;
      }
    }
  }
  return $router_path;
}