You are here

public static function RestfulBase::getMenuItem in RESTful 7

Get the non translated menu item.

Parameters

string $path: The path to match the router item. Leave it empty to use the current one.

Return value

array The page arguments.

See also

menu_get_item().

2 calls to RestfulBase::getMenuItem()
RestfulBase::getPageArguments in plugins/restful/RestfulBase.php
Get the resource name and version from the page arguments in the router.
restful_get_restful_handler_for_path in ./restful.module
Helper function to get the restful handler for the selected path.

File

plugins/restful/RestfulBase.php, line 1569
Contains RestfulBase.

Class

RestfulBase
Class \RestfulBase

Code

public static function getMenuItem($path = NULL) {
  $router_items =& drupal_static(__CLASS__ . '::' . __FUNCTION__);
  if (!isset($path)) {
    $path = $_GET['q'];
  }
  if (!isset($router_items[$path])) {
    $original_map = arg(NULL, $path);
    $parts = array_slice($original_map, 0, MENU_MAX_PARTS);
    $ancestors = menu_get_ancestors($parts);
    $router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(
      ':ancestors' => $ancestors,
    ))
      ->fetchAssoc();
    if ($router_item) {

      // Allow modules to alter the router item before it is translated and
      // checked for access.
      drupal_alter('menu_get_item', $router_item, $path, $original_map);
      $router_item['original_map'] = $original_map;
      if ($original_map === FALSE) {
        $router_items[$path] = FALSE;
        return FALSE;
      }
      $router_item['map'] = $original_map;
      $router_item['page_arguments'] = array_merge(menu_unserialize($router_item['page_arguments'], $original_map), array_slice($original_map, $router_item['number_parts']));
      $router_item['theme_arguments'] = array_merge(menu_unserialize($router_item['theme_arguments'], $original_map), array_slice($original_map, $router_item['number_parts']));
    }
    $router_items[$path] = $router_item;
  }
  return $router_items[$path];
}