class ResponseFactory implements ResponseFactoryInterface, ApplicationAwareInterface (View source)

Traits

Trait ApplicationAwareTrait A trait used with ApplicationAwareInterface

Properties

protected Application $app from  ApplicationAwareTrait
protected Session $session
protected Request $request
private Localization $localization
private Repository $config

Methods

setApplication(Application $app)

Setter method for the application

__construct(Session $session, Request $request, Localization $localization, Repository $config)

No description

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

Create a response

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

Create a response

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

Create a page not found response

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

Create an error response

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

Create a forbidden response

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

Create a redirect response

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

Create a response from a view object

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

Create a response from a controller object

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

Create a response from a collection object

collectionNotFound(Collection $collection, Request $request, array $headers)

No description

Details

setApplication(Application $app)

Setter method for the application

Parameters

Application $app

__construct(Session $session, Request $request, Localization $localization, Repository $config)

No description

Parameters

Session $session
Request $request
Localization $localization
Repository $config

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

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 = [])

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 = [])

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 = [])

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 = [])

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 = [])

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 = [])

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 = [])

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 = [])

Create a response from a collection object

Parameters

Collection $collection
int $code
array $headers

Return Value

Response

private collectionNotFound(Collection $collection, Request $request, array $headers)

No description

Parameters

Collection $collection
Request $request
array $headers