You are here

function js_callback_execute in JS Callback Handler 7.2

Execute a callback.

Parameters

array $info: The callback info array, passed by reference.

Return value

mixed The results of the callback.

1 call to js_callback_execute()
js_execute_request in ./js.module
Loads the requested module and executes the requested callback.

File

includes/callback.inc, line 17
callback.inc

Code

function js_callback_execute(array $info) {
  $xhprof = !empty($info['xhprof']) && function_exists('xhprof_enable') && function_exists('xhprof_disable');

  // If callback is being profiled, a full bootstrap is required.
  if ($xhprof) {
    $info['bootstrap'] = DRUPAL_BOOTSTRAP_FULL;
  }

  // Bootstrap the callback to minimal requirements.
  js_callback_bootstrap($info);

  // Process request data and append/replace arguments if necessary.
  js_callback_process_request($info);

  // By default, return JS_MENU_NOT_FOUND. This will be overridden below.
  $result = JS_MENU_NOT_FOUND;

  // Check callback access.
  if (!empty($info['access callback']) && !call_user_func_array($info['access callback'], $info['access arguments'])) {
    $result = JS_MENU_ACCESS_DENIED;
  }
  elseif (!empty($info['callback function']) || function_exists($info['callback function'])) {
    if ($xhprof) {
      xhprof_enable(0, array(
        'ignored_functions' => array(
          'call_user_func',
          'call_user_func_array',
        ),
      ));
    }

    // Execute the callback.
    $result = call_user_func_array($info['callback function'], $info['callback arguments']);
    if ($xhprof) {
      drupal_set_message('XHProf results:<ul><li>' . implode('</li><li>', array_keys(xhprof_disable())) . '</li></ul>');
    }

    // Enforce sensitization of the result if the "xss" variable is not
    // explicitly set to a boolean of FALSE.
    if ($info['xss'] !== FALSE) {
      $result = js_callback_filter_xss($result);
    }
  }
  return $result;
}