function js_deliver in JS Callback Handler 7.2
Sends content to the browser via the delivery callback.
Parameters
mixed $result: The content to pass to the delivery callback.
array $info: The callback definition array, may not be set.
2 calls to js_deliver()
- js_execute_request in ./
js.module - Loads the requested module and executes the requested callback.
- _js_log_php_error in ./
js.module - Logs a PHP error or exception and displays the error in fatal cases.
File
- ./
js.module, line 781 - JavaScript callback handler module.
Code
function js_deliver($result, array $info = NULL) {
// Capture buffered content.
$captured = ob_get_clean();
// If the callback definition array was not provided or the callback has
// explicitly disabled "capture", then allow loaded modules add the captured
// output to the result via hook_js_captured_content_alter().
if (!isset($info) || !empty($info['capture'])) {
drupal_alter('js_captured_content', $result, $captured);
}
else {
print $captured;
}
// Get the delivery callback to be used.
$delivery_callback = js_delivery_callback();
// Because a callback can specify a different delivery method, we don't need
// to load this include until it is absolutely necessary.
if ($delivery_callback === 'js_deliver_json') {
module_load_include('inc', 'js', 'includes/json');
}
// Deliver the results. The delivery callback is responsible for setting the
// appropriate headers, handling the result returned from the callback and
// exiting the script properly.
call_user_func_array($delivery_callback, array(
$result,
$info,
));
}