public function Js::deliver in JS Callback Handler 8.3
Sends content to the browser via the delivery callback.
Parameters
mixed $result: The content to pass to the delivery callback.
int $status_code: A status code to set for the response.
Return value
\Drupal\js\JsResponse A JsResponse object.
1 call to Js::deliver()
- Js::execute in src/
Js.php - Executes the requested JS Callback.
File
- src/
Js.php, line 199
Class
- Js
- JS Callback Handler service.
Namespace
Drupal\jsCode
public function deliver($result = [], $status_code = NULL) {
$response = $this
->getResponse();
if (isset($status_code)) {
$response
->setStatusCode($status_code);
}
// Capture buffered content.
if ($captured_content = ob_get_clean()) {
// If the callback has "capture_output" enabled, then allow extensions a
// chance to alter the response via hook_js_captured_content_alter().
if ($this
->getCallback()
->captureOutput()) {
$this
->alter('js_captured_content', $captured_content, $response, $this);
}
else {
print $captured_content;
}
}
// Check for redirection.
if ($redirection = $this
->checkForRedirection($result)) {
$response
->addCommand($redirection);
$result = [];
}
// Set the result as the data and return the response.
return $response
->setData($result);
}