Send a JSON HTTP response with the given output
public respondFromOutput ( mixed $output, string $hook_type = '', boolean $try_decode = true ) : Symfony\Component\HttpFoundation\JsonResponse | ||
$output | mixed | Output from a page/action handler |
$hook_type | string | The hook type. If given, the response will be filtered by hook |
$try_decode | boolean | Try to convert a JSON string back to an abject |
리턴 | Symfony\Component\HttpFoundation\JsonResponse |
public function testCanNotSendANewResponseAfterAjaxResponseFromOutputIsSent() { $service = $this->createService(); ob_start(); $json_response = $this->ajax->respondFromOutput('foo'); ob_get_clean(); $this->assertEquals($json_response, $service->send($service->prepareResponse('bar'))); }
/** * Send OK response * * @param string $content Response body * @param int $status_code HTTP status code * @param array $headers HTTP headers (will be discarded for AJAX requets) * @return type */ public function respondFromContent($content = '', $status_code = ELGG_HTTP_OK, array $headers = []) { if ($this->ajax->isReady()) { $hook_type = $this->parseContext(); // $this->ajax->setStatusCode($status_code); return $this->send($this->ajax->respondFromOutput($content, $hook_type)); } return $this->send($this->prepareResponse($content, $status_code, $headers)); }