You are here

function crumbs_Router::getRouterItem in Crumbs, the Breadcrumbs suite 7.2

Returns a router item.

This is a wrapper around menu_get_item() that sets additional keys (route, link_path, alias, fragments).

Parameters

$path: The path for which the corresponding router item is returned. For example, node/5.

Return value

array|null The router item.

1 call to crumbs_Router::getRouterItem()
crumbs_Router::reducePath in lib/Router.php
Chop off path fragments until we find a valid path.

File

lib/Router.php, line 26

Class

crumbs_Router
Wrapper for routing-related Drupal core functions.

Code

function getRouterItem($path) {
  $normalpath = drupal_get_normal_path($path);
  try {
    $item = menu_get_item($normalpath);
  } catch (Exception $e) {

    // Some modules throw an exception, if a path has unloadable arguments.
    // We don't care, because we don't actually load this page.
    return NULL;
  }

  // Some additional keys.
  if (empty($item) || !is_array($item)) {
    return NULL;
  }

  // 'route' is a less ambiguous name for a router path than 'path'.
  $item['route'] = $item['path'];

  // 'href' sounds more like it had already run through url().
  $item['link_path'] = $normalpath;
  $item['alias'] = drupal_get_path_alias($normalpath);
  $item['fragments'] = explode('/', $normalpath);
  if (!isset($item['localized_options'])) {
    $item['localized_options'] = array();
  }
  if ('crumbs_special_menu_link_page' === $item['page_callback']) {
    $item['href'] = '<nolink>';
  }
  if ($normalpath !== $item['href']) {
    $pos = strlen($item['href']);
    $item['variadic_suffix'] = substr($normalpath, $pos);
  }
  else {
    $item['variadic_suffix'] = NULL;
  }
  return $item;
}