Elgg\Ajax\Service::filterApiResponse PHP Method

filterApiResponse() private method

Filter an AjaxResponse through a plugin hook
private filterApiResponse ( Elgg\Services\AjaxResponse $api_response, string $hook_type = '' ) : Elgg\Services\AjaxResponse
$api_response Elgg\Services\AjaxResponse The API Response
$hook_type string The hook type. If given, the response will be filtered by hook
return Elgg\Services\AjaxResponse
    private function filterApiResponse(AjaxResponse $api_response, $hook_type = '')
    {
        $api_response->setTtl($this->input->get('elgg_response_ttl', 0, false));
        if ($hook_type) {
            $hook = AjaxResponse::RESPONSE_HOOK;
            $api_response = $this->hooks->trigger($hook, $hook_type, null, $api_response);
            if (!$api_response instanceof AjaxResponse) {
                throw new RuntimeException("The value returned by hook [{$hook}, {$hook_type}] was not an ApiResponse");
            }
        }
        return $api_response;
    }