Method | Description | |
---|---|---|
__construct ( |
Constructor | |
appendDeps ( string $hook, string $type, Elgg\Services\AjaxResponse $response, array $params ) : Elgg\Services\AjaxResponse | Send required AMD modules list back with the response | |
appendMessages ( string $hook, string $type, Elgg\Services\AjaxResponse $response, array $params ) : Elgg\Services\AjaxResponse | Send system messages back with the response | |
decodeJson ( mixed $string ) : mixed | Attempt to JSON decode the given string | |
getViews ( ) : string[] | Returns an array of views allowed for ajax calls | |
isAjax2Request ( ) : boolean | Did the request come from the elgg/Ajax module? | |
isReady ( ) : boolean | Is the service ready to respond to the request? | |
registerView ( string $view ) : void | Register a view to be available for ajax calls | |
respondFromApiResponse ( Elgg\Services\AjaxResponse $api_response, string $hook_type = '' ) : Symfony\Component\HttpFoundation\JsonResponse | Send a JSON HTTP response based on the given API response | |
respondFromOutput ( mixed $output, string $hook_type = '', boolean $try_decode = true ) : Symfony\Component\HttpFoundation\JsonResponse | Send a JSON HTTP response with the given output | |
respondWithError ( string $msg = '', integer $status = 400 ) : Symfony\Component\HttpFoundation\JsonResponse | Send a JSON HTTP 400 response | |
unregisterView ( string $view ) : void | Unregister a view for ajax calls |
Method | Description | |
---|---|---|
buildHttpResponse ( Elgg\Services\AjaxResponse $api_response, boolean $allow_removing_headers = null ) : Symfony\Component\HttpFoundation\JsonResponse | Build a JsonResponse based on an API response object | |
filterApiResponse ( Elgg\Services\AjaxResponse $api_response, string $hook_type = '' ) : Elgg\Services\AjaxResponse | Filter an AjaxResponse through a plugin hook |
public __construct ( |
||
$hooks | Hooks service | |
$msgs | System messages service | |
$input | Input service | |
$amdConfig | Elgg\Amd\Config | AMD config |
public decodeJson ( mixed $string ) : mixed | ||
$string | mixed | Output string |
return | mixed |
public getViews ( ) : string[] | ||
return | string[] |
public isAjax2Request ( ) : boolean | ||
return | boolean |
public registerView ( string $view ) : void | ||
$view | string | The view name |
return | void |
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 |
return | Symfony\Component\HttpFoundation\JsonResponse |
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 |
return | Symfony\Component\HttpFoundation\JsonResponse |
public respondWithError ( string $msg = '', integer $status = 400 ) : Symfony\Component\HttpFoundation\JsonResponse | ||
$msg | string | The error message (not displayed to the user) |
$status | integer | The HTTP status code |
return | Symfony\Component\HttpFoundation\JsonResponse |
public unregisterView ( string $view ) : void | ||
$view | string | The view name |
return | void |