You are here

function restful_page_delivery_callback_alter in RESTful 7.2

Same name and namespace in other branches
  1. 7 restful.module \restful_page_delivery_callback_alter()

Implements hook_page_delivery_callback_alter().

Hijack api/* to be under RESTful. We make sure that any call to api/* pages that isn't valid, will still return with a well formatted error, instead of a 404 HTML page.

File

./restful.module, line 466

Code

function restful_page_delivery_callback_alter(&$callback) {
  if (!variable_get('restful_hijack_api_pages', TRUE)) {
    return;
  }
  $base_path = variable_get('restful_hook_menu_base_path', 'api');
  if (strpos($_GET['q'], $base_path . '/') !== 0 && $_GET['q'] != $base_path) {

    // Page doesn't start with the base path (e.g. "api" or "api/").
    return;
  }
  if (menu_get_item()) {

    // Path is valid (i.e. not 404).
    return;
  }
  $callback = 'restful_deliver_menu_not_found';
}