abstract class Handler

Base handler.

Traits

Basic content negotiation.

Properties

Request $request from ContentNegotiationTrait
Response $response from ContentNegotiationTrait

Methods

bool
expectsType(array $mimeTypes, string|null $suffix = null)

Does the client expect the provided mime type?

bool
expectsJson()

Does the client expect JSON?

bool
expectsXml()

Does the client expect XML?

bool
respondWithType(array $mimeTypes, string|null $suffix = null)

Should we respond with the provided mime type?

bool
respondWithJson()

Should we respond with JSON?

bool
respondWithXml()

Should we respond with XML?

int
getStatusCode(Throwable $exception)

Returns the status code that we should send.

sendResponse(Response $response, Throwable $exception)

Sends response and adds any aditional headers.

Details

protected bool expectsType(array $mimeTypes, string|null $suffix = null)

Does the client expect the provided mime type?

Parameters

array $mimeTypes Mime types
string|null $suffix Mime type suffix

Return Value

bool

protected bool expectsJson()

Does the client expect JSON?

Return Value

bool

protected bool expectsXml()

Does the client expect XML?

Return Value

bool

protected bool respondWithType(array $mimeTypes, string|null $suffix = null)

Should we respond with the provided mime type?

Parameters

array $mimeTypes Mime types
string|null $suffix Mime type suffix

Return Value

bool

protected bool respondWithJson()

Should we respond with JSON?

Return Value

bool

protected bool respondWithXml()

Should we respond with XML?

Return Value

bool

at line 31
protected int getStatusCode(Throwable $exception)

Returns the status code that we should send.

Parameters

Throwable $exception Exception

Return Value

int

at line 42
protected sendResponse(Response $response, Throwable $exception)

Sends response and adds any aditional headers.

Parameters

Response $response Response
Throwable $exception Exception