PHP Класс Elgg\Http\ResponseFactory

С версии: 2.3
Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( Request $request, PluginHooksService $hooks, Service $ajax, Elgg\Http\ResponseTransport $transport ) Constructor
getHeaders ( boolean $remove_existing = true ) : ResponseHeaderBag Get headers set to apply to all responses
getSentResponse ( ) : Response | false Returns a response that was sent to the client
isAction ( ) : boolean Check if the requested path is an action
isXhr ( ) : boolean Check if the request is an XmlHttpRequest
normalize ( mixed $content = '' ) : mixed Normalizes content into serializable data by walking through arrays and objectifying Elgg entities
parseContext ( ) : string Parses response type to be used as plugin hook type
prepareRedirectResponse ( string $url, integer $status = 302, array $headers = [] ) : RedirectResponse Creates a redirect response
prepareResponse ( string $content = '', integer $status = 200, array $headers = [] ) : Response Creates an HTTP response
redirect ( string $forward_url = REFERRER, mixed $status_code = ELGG_HTTP_FOUND ) : RedirectResponse Prepares a redirect response
respond ( Elgg\Http\ResponseBuilder $response ) : Response Send HTTP response
respondFromContent ( string $content = '', integer $status_code = ELGG_HTTP_OK, array $headers = [] ) : type Send OK response
respondWithError ( string $error, integer $status_code = ELGG_HTTP_BAD_REQUEST, array $headers = [] ) : Response Send error HTTP response
send ( Response $response ) : Response Send a response
setHeader ( string $name, string $value, boolean $replace = true ) : void Sets headers to apply to all responses being sent
stringify ( mixed $content = '' ) : string Stringify/serialize response data
wrapLegacyAjaxResponse ( string $content = '', string $forward_url = REFERRER ) : string Wraps content for compability with legacy Elgg ajax calls

Описание методов

__construct() публичный Метод

Constructor
public __construct ( Request $request, PluginHooksService $hooks, Service $ajax, Elgg\Http\ResponseTransport $transport )
$request Request HTTP request
$hooks Elgg\PluginHooksService Plugin hooks service
$ajax Elgg\Ajax\Service AJAX service
$transport Elgg\Http\ResponseTransport Response transport

getHeaders() публичный Метод

Get headers set to apply to all responses
public getHeaders ( boolean $remove_existing = true ) : ResponseHeaderBag
$remove_existing boolean Remove existing headers found in headers_list()
Результат Symfony\Component\HttpFoundation\ResponseHeaderBag

getSentResponse() публичный Метод

Returns a response that was sent to the client
public getSentResponse ( ) : Response | false
Результат Symfony\Component\HttpFoundation\Response | false

isAction() публичный Метод

Check if the requested path is an action
public isAction ( ) : boolean
Результат boolean

isXhr() публичный Метод

Check if the request is an XmlHttpRequest
public isXhr ( ) : boolean
Результат boolean

normalize() публичный Метод

Normalizes content into serializable data by walking through arrays and objectifying Elgg entities
public normalize ( mixed $content = '' ) : mixed
$content mixed Data to normalize
Результат mixed

parseContext() публичный Метод

Parses response type to be used as plugin hook type
public parseContext ( ) : string
Результат string

prepareRedirectResponse() публичный Метод

Creates a redirect response
public prepareRedirectResponse ( string $url, integer $status = 302, array $headers = [] ) : RedirectResponse
$url string URL to redirect to
$status integer The status code (302 by default)
$headers array An array of response headers (Location is always set to the given URL)
Результат Symfony\Component\HttpFoundation\RedirectResponse

prepareResponse() публичный Метод

Creates an HTTP response
public prepareResponse ( string $content = '', integer $status = 200, array $headers = [] ) : Response
$content string The response content
$status integer The response status code
$headers array An array of response headers
Результат Symfony\Component\HttpFoundation\Response

redirect() публичный Метод

Prepares a redirect response
public redirect ( string $forward_url = REFERRER, mixed $status_code = ELGG_HTTP_FOUND ) : RedirectResponse
$forward_url string Redirection URL
$status_code mixed HTTP status code or forward reason
Результат Symfony\Component\HttpFoundation\RedirectResponse

respond() публичный Метод

Send HTTP response
public respond ( Elgg\Http\ResponseBuilder $response ) : Response
$response Elgg\Http\ResponseBuilder ResponseBuilder instance An instance of an ErrorResponse, OkResponse or RedirectResponse
Результат Symfony\Component\HttpFoundation\Response

respondFromContent() публичный Метод

Send OK response
public respondFromContent ( string $content = '', integer $status_code = ELGG_HTTP_OK, array $headers = [] ) : type
$content string Response body
$status_code integer HTTP status code
$headers array HTTP headers (will be discarded for AJAX requets)
Результат type

respondWithError() публичный Метод

Send error HTTP response
public respondWithError ( string $error, integer $status_code = ELGG_HTTP_BAD_REQUEST, array $headers = [] ) : Response
$error string Error message
$status_code integer HTTP status code
$headers array HTTP headers (will be discarded on AJAX requests)
Результат Symfony\Component\HttpFoundation\Response

send() публичный Метод

Send a response
public send ( Response $response ) : Response
$response Symfony\Component\HttpFoundation\Response Response object
Результат Symfony\Component\HttpFoundation\Response

setHeader() публичный Метод

Sets headers to apply to all responses being sent
public setHeader ( string $name, string $value, boolean $replace = true ) : void
$name string Header name
$value string Header value
$replace boolean Replace existing headers
Результат void

stringify() публичный Метод

Casts objects implementing __toString method to strings Serializes non-scalar values to JSON
public stringify ( mixed $content = '' ) : string
$content mixed Content to serialize
Результат string

wrapLegacyAjaxResponse() публичный Метод

Wraps content for compability with legacy Elgg ajax calls
public wrapLegacyAjaxResponse ( string $content = '', string $forward_url = REFERRER ) : string
$content string Response content
$forward_url string Forward URL
Результат string