You are here

protected static function ResourceManager::getMenuItem in RESTful 7.2

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 ResourceManager::getMenuItem()
ResourceManager::getPageArguments in src/Resource/ResourceManager.php
Get the resource name and version from the page arguments in the router.
ResourceManager::getPageCallback in src/Resource/ResourceManager.php
Get the menu item callback.

File

src/Resource/ResourceManager.php, line 294
Contains \Drupal\restful\Resource\ResourceManager.

Class

ResourceManager

Namespace

Drupal\restful\Resource

Code

protected static function getMenuItem($path = NULL) {
  $router_items =& drupal_static(__METHOD__);
  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];
}