Elgg
Version master
|
HTTP response service. More...
Public Member Functions | |
__construct (protected Request $request, protected AjaxService $ajax, protected EventsService $events) | |
Constructor. More... | |
setHeader (string $name, string $value, bool $replace=true) | |
Sets headers to apply to all responses being sent. More... | |
setCookie (\ElggCookie $cookie) | |
Set a cookie, but allow plugins to customize it first. More... | |
getHeaders (bool $remove_existing=true) | |
Get headers set to apply to all responses. More... | |
prepareResponse (?string $content= '', int $status=200, array $headers=[]) | |
Creates an HTTP response. More... | |
prepareRedirectResponse (string $url, int $status=302, array $headers=[]) | |
Creates a redirect response. More... | |
prepareJsonResponse ($content= '', int $status=200, array $headers=[]) | |
Creates an JSON response. More... | |
send (SymfonyResponse $response) | |
Send a response. More... | |
getSentResponse () | |
Returns a response that was sent to the client. More... | |
respond (ResponseBuilder $response) | |
Send HTTP response. More... | |
respondWithError (ResponseBuilder $response) | |
Send error HTTP response. More... | |
respondFromContent (ResponseBuilder $response) | |
Send OK response. More... | |
wrapAjaxResponse ($content= '', string $forward_url=null) | |
Wraps response content in an Ajax2 compatible format. More... | |
redirect (string $forward_url=REFERRER, $status_code=ELGG_HTTP_FOUND) | |
Prepares a redirect response. More... | |
parseContext () | |
Parses response type to be used as event 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... | |
setTransport (ResponseTransport $transport) | |
Replaces response transport. More... | |
Protected Member Functions | |
getSiteRefererUrl () | |
Ensures the referer header is a site url. More... | |
makeSecureForwardUrl (string $url) | |
Ensure the url has a valid protocol for browser use. More... | |
closeSession () | |
Closes the session. More... | |
Protected Attributes | |
ResponseTransport | $transport |
ResponseHeaderBag | $headers |
SymfonyResponse | $response_sent = null |
Elgg\Http\ResponseFactory::__construct | ( | protected Request | $request, |
protected AjaxService | $ajax, | ||
protected EventsService | $events | ||
) |
Constructor.
Request | $request | HTTP request |
AjaxService | $ajax | AJAX service |
EventsService | $events | Events service |
Definition at line 38 of file ResponseFactory.php.
|
protected |
Closes the session.
Force closing the session so session is saved to the database before headers are sent preventing race conditions with session data
Definition at line 633 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::getHeaders | ( | bool | $remove_existing = true | ) |
Get headers set to apply to all responses.
bool | $remove_existing | Remove existing headers found in headers_list() |
Definition at line 95 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::getSentResponse | ( | ) |
Returns a response that was sent to the client.
Definition at line 219 of file ResponseFactory.php.
|
protected |
Ensures the referer header is a site url.
Definition at line 603 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::isAction | ( | ) |
Check if the requested path is an action.
Definition at line 533 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::isXhr | ( | ) |
Check if the request is an XmlHttpRequest.
Definition at line 524 of file ResponseFactory.php.
|
protected |
Ensure the url has a valid protocol for browser use.
string | $url | url the secure |
Definition at line 614 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 event type.
Definition at line 491 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::prepareJsonResponse | ( | $content = '' , |
|
int | $status = 200 , |
||
array | $headers = [] |
||
) |
Creates an JSON response.
mixed | $content | The response content |
integer | $status | The response status code |
array | $headers | An array of response headers |
Removing Content-Type header because in some cases content-type headers were already set This is a problem when serving a cachable view (for example a .css) in ajax/view
Definition at line 159 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::prepareRedirectResponse | ( | string | $url, |
int | $status = 302 , |
||
array | $headers = [] |
||
) |
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) |
Definition at line 141 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::prepareResponse | ( | ?string | $content = '' , |
int | $status = 200 , |
||
array | $headers = [] |
||
) |
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 123 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::redirect | ( | string | $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 |
UnexpectedValueException |
Definition at line 405 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 |
UnexpectedValueException |
Definition at line 233 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::respondFromContent | ( | ResponseBuilder | $response | ) |
Send OK response.
ResponseBuilder | $response | ResponseBuilder instance An instance of an ErrorResponse, OkResponse or RedirectResponse |
Definition at line 364 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::respondWithError | ( | ResponseBuilder | $response | ) |
Send error HTTP response.
ResponseBuilder | $response | ResponseBuilder instance An instance of an ErrorResponse, OkResponse or RedirectResponse |
Definition at line 305 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::send | ( | SymfonyResponse | $response | ) |
Send a response.
SymfonyResponse | $response | Response object |
Definition at line 183 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::setCookie | ( | \ElggCookie | $cookie | ) |
Set a cookie, but allow plugins to customize it first.
To customize all cookies, register for the 'init:cookie', 'all' event.
\ElggCookie | $cookie | The cookie that is being set |
Definition at line 69 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::setHeader | ( | string | $name, |
string | $value, | ||
bool | $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 56 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::setTransport | ( | ResponseTransport | $transport | ) |
Replaces response transport.
ResponseTransport | $transport | Transport interface |
Definition at line 594 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 569 of file ResponseFactory.php.
Elgg\Http\ResponseFactory::wrapAjaxResponse | ( | $content = '' , |
|
string | $forward_url = null |
||
) |
Wraps response content in an Ajax2 compatible format.
string | $content | Response content |
string | $forward_url | Forward URL |
Definition at line 382 of file ResponseFactory.php.
|
protected |
Definition at line 27 of file ResponseFactory.php.
|
protected |
Definition at line 29 of file ResponseFactory.php.
|
protected |
Definition at line 25 of file ResponseFactory.php.