interface ResponseFactoryInterface (View source)

Methods

Response
create(string $content, int $code = Response::HTTP_OK, array $headers = array())

Create a response

Response
json(array|object|JsonSerializable $data, int $code = Response::HTTP_OK, array $headers = array())

Create a response

Response
notFound(string $content, int $code = Response::HTTP_NOT_FOUND, array $headers = array())

Create a page not found response

Response
error(string $content, int $code = Response::HTTP_INTERNAL_SERVER_ERROR, array $headers = array())

Create an error response

Response
forbidden(string $requestUrl, int $code = Response::HTTP_FORBIDDEN, array $headers = array())

Create a forbidden response

Response
redirect(string $to, int $code = Response::HTTP_MOVED_PERMANENTLY, array $headers = array())

Create a redirect response

Response
view(View $view, int $code = Response::HTTP_OK, array $headers = array())

Create a response from a view object

Response
controller(Controller $controller, int $code = Response::HTTP_OK, array $headers = array())

Create a response from a controller object

Response
collection(Collection $collection, int $code = Response::HTTP_OK, array $headers = array())

Create a response from a collection object

Details

Response create(string $content, int $code = Response::HTTP_OK, array $headers = array())

Create a response

Parameters

string $content The body of the response
int $code The response code
array $headers Optional headers to include

Return Value

Response

Response json(array|object|JsonSerializable $data, int $code = Response::HTTP_OK, array $headers = array())

Create a response

Parameters

array|object|JsonSerializable $data The json data
int $code The response code
array $headers Optional headers to include

Return Value

Response

Response notFound(string $content, int $code = Response::HTTP_NOT_FOUND, array $headers = array())

Create a page not found response

Parameters

string $content The body of the response
int $code The response code
array $headers Optional headers to include

Return Value

Response

Response error(string $content, int $code = Response::HTTP_INTERNAL_SERVER_ERROR, array $headers = array())

Create an error response

Parameters

string $content The body of the response
int $code The response code
array $headers Optional headers to include

Return Value

Response

Response forbidden(string $requestUrl, int $code = Response::HTTP_FORBIDDEN, array $headers = array())

Create a forbidden response

Parameters

string $requestUrl The url that this requests used. This will be used to redirect after login
int $code The response code
array $headers Optional headers to include

Return Value

Response

Response redirect(string $to, int $code = Response::HTTP_MOVED_PERMANENTLY, array $headers = array())

Create a redirect response

Parameters

string $to The URL to redirect to
int $code The response code
array $headers Optional headers to include

Return Value

Response

Response view(View $view, int $code = Response::HTTP_OK, array $headers = array())

Create a response from a view object

Parameters

View $view
int $code
array $headers

Return Value

Response

Response controller(Controller $controller, int $code = Response::HTTP_OK, array $headers = array())

Create a response from a controller object

Parameters

Controller $controller
int $code
array $headers

Return Value

Response

Response collection(Collection $collection, int $code = Response::HTTP_OK, array $headers = array())

Create a response from a collection object

Parameters

Collection $collection
int $code
array $headers

Return Value

Response