You are here

function _menu_link_path in Menu Link (Field) 7

Helper function to build a menu link path based on an entity.

2 calls to _menu_link_path()
menu_link_field_insert in ./menu_link.field.inc
Implements hook_field_insert().
menu_link_field_update in ./menu_link.field.inc
Implements hook_field_update().

File

./menu_link.field.inc, line 288
Defines a menu link field type.

Code

function _menu_link_path($entity_type, $entity, $langcode) {
  $uri = entity_uri($entity_type, $entity);
  if (url_is_external($uri['path'])) {
    $path = url($uri['path'], $uri['options']);
  }
  else {
    $path = drupal_get_normal_path($uri['path'], $langcode);
    if (!empty($uri['options']['query'])) {
      $path .= (strpos($path, '?') !== FALSE ? '&' : '?') . drupal_http_build_query($uri['options']['query']);
    }
    if (!empty($uri['options']['fragment'])) {
      $path .= '#' . $uri['options']['fragment'];
    }
  }
  return $path;
}