public respondFromApiResponse ( Elgg\Services\AjaxResponse $api_response, string $hook_type = '' ) : Symfony\Component\HttpFoundation\JsonResponse | ||
$api_response | Elgg\Services\AjaxResponse | API response |
$hook_type | string | The hook type. If given, the response will be filtered by hook |
리턴 | Symfony\Component\HttpFoundation\JsonResponse |
public function respondFromApiResponse(AjaxResponse $api_response, $hook_type = '')
{
$api_response = $this->filterApiResponse($api_response, $hook_type);
$response = $this->buildHttpResponse($api_response);
$this->response_sent = true;
return _elgg_services()->responseFactory->send($response);
}
public function testCanNotSendANewResponseAfterAjaxResponseFromApiResponseIsSent() { $service = $this->createService(); $api_response = new \Elgg\Ajax\Response(); $api_response->setData((object) ['value' => 'foo']); ob_start(); $json_response = $this->ajax->respondFromApiResponse($api_response); ob_get_clean(); $this->assertEquals($json_response, $service->send($service->prepareResponse('bar'))); }