|
Elgg
Version 2.3
|
WARNING: API IN FLUX. More...
Public Member Functions | |
| __construct (Request $request, PluginHooksService $hooks, AjaxService $ajax, ResponseTransport $transport) | |
| Constructor. More... | |
| setHeader ($name, $value, $replace=true) | |
| Sets headers to apply to all responses being sent. More... | |
| getHeaders ($remove_existing=true) | |
| Get headers set to apply to all responses. More... | |
| prepareResponse ($content='', $status=200, array $headers=array()) | |
| Creates an HTTP response. More... | |
| prepareRedirectResponse ($url, $status=302, array $headers=array()) | |
| Creates a redirect response. More... | |
| send (Response $response) | |
| Send a response. More... | |
| getSentResponse () | |
| Returns a response that was sent to the client. More... | |
| respond (ResponseBuilder $response) | |
| Send HTTP response. More... | |
| respondWithError ($error, $status_code=ELGG_HTTP_BAD_REQUEST, array $headers=[]) | |
| Send error HTTP response. More... | |
| respondFromContent ($content='', $status_code=ELGG_HTTP_OK, array $headers=[]) | |
| Send OK response. More... | |
| wrapLegacyAjaxResponse ($content='', $forward_url=REFERRER) | |
| Wraps content for compability with legacy Elgg ajax calls. More... | |
| redirect ($forward_url=REFERRER, $status_code=ELGG_HTTP_FOUND) | |
| Prepares a redirect response. More... | |
| parseContext () | |
| Parses response type to be used as plugin hook type. More... | |
| isXhr () | |
| Check if the request is an XmlHttpRequest. More... | |
| isAction () | |
| Check if the requested path is an action. More... | |
| normalize ($content='') | |
| Normalizes content into serializable data by walking through arrays and objectifying Elgg entities. More... | |
| stringify ($content='') | |
| Stringify/serialize response data. More... | |
WARNING: API IN FLUX.
DO NOT USE DIRECTLY.
Definition at line 20 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::__construct | ( | Request | $request, |
| PluginHooksService | $hooks, | ||
| AjaxService | $ajax, | ||
| ResponseTransport | $transport | ||
| ) |
Constructor.
| Request | $request | HTTP request |
| PluginHooksService | $hooks | Plugin hooks service |
| AjaxService | $ajax | AJAX service |
| ResponseTransport | $transport | Response transport |
Definition at line 60 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::getHeaders | ( | $remove_existing = true | ) |
Get headers set to apply to all responses.
| bool | $remove_existing | Remove existing headers found in headers_list() |
Definition at line 86 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::getSentResponse | ( | ) |
Returns a response that was sent to the client.
Definition at line 173 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::isAction | ( | ) |
Check if the requested path is an action.
Definition at line 531 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::isXhr | ( | ) |
Check if the request is an XmlHttpRequest.
Definition at line 523 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::normalize | ( | $content = '' | ) |
Normalizes content into serializable data by walking through arrays and objectifying Elgg entities.
| mixed | $content | Data to normalize |
Definition at line 545 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::parseContext | ( | ) |
Parses response type to be used as plugin hook type.
Definition at line 491 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::prepareRedirectResponse | ( | $url, | |
$status = 302, |
|||
| array | $headers = array() |
||
| ) |
Creates a redirect response.
| string | $url | URL to redirect to |
| integer | $status | The status code (302 by default) |
| array | $headers | An array of response headers (Location is always set to the given URL) |
| InvalidArgumentException |
Definition at line 130 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::prepareResponse | ( | $content = '', |
|
$status = 200, |
|||
| array | $headers = array() |
||
| ) |
Creates an HTTP response.
| string | $content | The response content |
| integer | $status | The response status code |
| array | $headers | An array of response headers |
Definition at line 113 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::redirect | ( | $forward_url = REFERRER, |
|
$status_code = ELGG_HTTP_FOUND |
|||
| ) |
Prepares a redirect response.
| string | $forward_url | Redirection URL |
| mixed | $status_code | HTTP status code or forward reason |
| InvalidParameterException |
Definition at line 378 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::respond | ( | ResponseBuilder | $response | ) |
Send HTTP response.
| ResponseBuilder | $response | ResponseBuilder instance An instance of an ErrorResponse, OkResponse or RedirectResponse |
Definition at line 184 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::respondFromContent | ( | $content = '', |
|
$status_code = ELGG_HTTP_OK, |
|||
| array | $headers = [] |
||
| ) |
Send OK response.
| string | $content | Response body |
| int | $status_code | HTTP status code |
| array | $headers | HTTP headers (will be discarded for AJAX requets) |
Definition at line 308 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::respondWithError | ( | $error, | |
$status_code = ELGG_HTTP_BAD_REQUEST, |
|||
| array | $headers = [] |
||
| ) |
Send error HTTP response.
| string | $error | Error message |
| int | $status_code | HTTP status code |
| array | $headers | HTTP headers (will be discarded on AJAX requests) |
| InvalidParameterException |
Definition at line 263 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::send | ( | Response | $response | ) |
Send a response.
| Response | $response | Response object |
Definition at line 144 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::setHeader | ( | $name, | |
| $value, | |||
$replace = true |
|||
| ) |
Sets headers to apply to all responses being sent.
| string | $name | Header name |
| string | $value | Header value |
| bool | $replace | Replace existing headers |
Definition at line 76 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::stringify | ( | $content = '' | ) |
Stringify/serialize response data.
Casts objects implementing __toString method to strings Serializes non-scalar values to JSON
| mixed | $content | Content to serialize |
Definition at line 566 of file ResponseFactory.php.
| Elgg\Http\ResponseFactory::wrapLegacyAjaxResponse | ( | $content = '', |
|
$forward_url = REFERRER |
|||
| ) |
Wraps content for compability with legacy Elgg ajax calls.
| string | $content | Response content |
| string | $forward_url | Forward URL |
Definition at line 326 of file ResponseFactory.php.