\Gishiki\Core\MVC\Controller\PluginsResponseSerializer

This is a plugin used to generate data to be transported by the HTTP response.

Summary

Methods
Properties
Constants
__construct()
getResponse()
getRequest()
getRequestAcceptedType()
setResponseContentType()
setResponseSerialized()
No public properties found
ALLOWED_TYPES
DEFAULT_TYPE
No protected methods found
$request
$response
$application
N/A
No private methods found
No private properties found
N/A

Constants

ALLOWED_TYPES

ALLOWED_TYPES

DEFAULT_TYPE

DEFAULT_TYPE

Properties

$request

$request : \Psr\Http\Message\RequestInterface

Type

\Psr\Http\Message\RequestInterface — reference to the HTTP request

$response

$response : \Psr\Http\Message\ResponseInterface

Type

\Psr\Http\Message\ResponseInterface — reference to the HTTP response

$application

$application : \Gishiki\Core\Application|null

Type

\Gishiki\Core\Application|null — the application current instance

Methods

__construct()

__construct(\Psr\Http\Message\RequestInterface  $request, \Psr\Http\Message\ResponseInterface  $response, \Gishiki\Core\Application|null  $app = null) 

Serializer constructor: setup the plugin importing serializers

Warning: you should never attempt to use another construction in your plugin, unless it calls parent::__construct()

Parameters

\Psr\Http\Message\RequestInterface $request

the HTTP request

\Psr\Http\Message\ResponseInterface $response

the HTTP response

\Gishiki\Core\Application|null $app

the current application instance

getResponse()

getResponse() : \Psr\Http\Message\ResponseInterface

Get the HTTP response.

Returns

\Psr\Http\Message\ResponseInterface —

the HTTP response

getRequest()

getRequest() : \Psr\Http\Message\RequestInterface

Get the HTTP request.

Returns

\Psr\Http\Message\RequestInterface —

the HTTP request

getRequestAcceptedType()

getRequestAcceptedType() : string

Get the best accepted serialization format.

If a compatible one is not provided than the default one is returned.

Returns

string —

the accepted content type OR the default one

setResponseContentType()

setResponseContentType(string  $type) 

Set the used serialization format.

This function should be called only once by setResponseSerialized().

Parameters

string $type

the used serialization format

setResponseSerialized()

setResponseSerialized(\Gishiki\Algorithms\Collections\SerializableCollection  $data) 

Serialize given data using the best suitable serialization format.

Write the result to the response body and place the format into the Content-Type HTTP header.

Parameters

\Gishiki\Algorithms\Collections\SerializableCollection $data

the data to be serialized