You are here

function httprl_run_callback in HTTP Parallel Request & Threading Library 6

Same name and namespace in other branches
  1. 7 httprl.module \httprl_run_callback()

Run callback.

Will run the given callback returning values and what might have been printed by that function, as well as respecting any pass by reference values.

Parameters

object $result: An object from httprl_send_request.

1 call to httprl_run_callback()
httprl_post_processing in ./httprl.module
Run post processing on the request if we are done reading.

File

./httprl.module, line 2174
HTTP Parallel Request Library module.

Code

function httprl_run_callback(&$result) {

  // Get options.
  $callback_options = $result->options['callback'][0];

  // Merge in values by reference.
  $result->options['callback'][0] =& $result;

  // Capture anything printed out.
  ob_start();

  // Call function.
  $callback_options['return'] = call_user_func_array($callback_options['function'], $result->options['callback']);
  if (array_key_exists('printed', $callback_options)) {

    // Return printed output if requested to do so.
    $callback_options['printed'] = ob_get_contents();
  }
  ob_end_clean();

  // Add options back into the callback array.
  if (isset($result->options['callback'])) {
    array_unshift($result->options['callback'], $callback_options);
  }
}