You are here

function _boost_get_menu_router in Boost 7

Same name and namespace in other branches
  1. 6 boost.module \_boost_get_menu_router()

Gets menu router contex.

Allows for any content type to have it's own cache expiration among other things.

Parameters

$parts:

Return value

$parts

1 call to _boost_get_menu_router()
boost_transform_url in ./boost.module
Given a URL give back eveything we know.

File

./boost.module, line 829
Caches generated output as a static file to be served directly from the webserver.

Code

function _boost_get_menu_router($parts) {

  // Declare array keys.
  $router_item = array();
  $router_item['page_type'] = '';
  $router_item['page_id'] = '';

  // Load the menu item.
  $item = menu_get_item($parts['normal_path']);
  if (is_array($item)) {
    $router_item += $item;
    if ($router_item['access']) {
      $router_item['status'] = 200;
    }
    else {
      $router_item['status'] = 403;
    }
  }
  else {
    $router_item['status'] = 404;
  }

  // Get any extra arguments.
  if (!empty($router_item['path'])) {
    $menu_args = arg(NULL, $router_item['path']);
    $diff = array();
    foreach ($parts['args'] as $key => $value) {
      if (!empty($value)) {
        if (isset($menu_args[$key])) {
          if ($value !== $menu_args[$key] && $menu_args[$key] !== '%') {
            $diff[] = $value;
          }
        }
        else {
          $diff[] = $value;
        }
      }
    }
  }
  if (!empty($diff)) {
    $router_item['extra_arguments'] = implode('/', $diff);
  }
  else {
    $router_item['extra_arguments'] = '';
  }

  // Make sure function for menu callback is loaded.
  // See menu_execute_active_handler()
  if (!empty($router_item['include_file'])) {
    require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
  }
  $parts['menu_item'] = $router_item;

  // Invoke hook_boost_menu_router($router_item).
  $modules = boost_module_implements('boost_menu_router', 'boost');
  foreach ($modules as $module) {
    if (($result = module_invoke($module, 'boost_menu_router', $parts)) !== NULL) {
      break;
    }
  }

  // Remove extra data from the load function.
  unset($result['menu_item']['map'], $result['menu_item']['page_arguments']);
  return $result;
}