class RequestUtil

Methods

static bool
isApiRequest(ServerRequestInterface $request)

Determine if the request is an API request. We do not manually set the `Accepts` header for API requests, so we need to check the priority list to determine whether it is or not.

static bool
isHtmlRequest(ServerRequestInterface $request)

No description

static string
getPreferredContentType(ServerRequestInterface $request, array $types)

Determine the client's preferred content type out of the given list.

static User
getActor(ServerRequestInterface $request)

No description

static ServerRequestInterface
withActor(ServerRequestInterface $request, User $actor)

No description

static array|null
extractSort(ServerRequestInterface $request, string|null $default, array $available = [])

No description

static int|null
extractLimit(ServerRequestInterface $request, int|null $defaultLimit = null, int|null $max = null)

No description

static int
extractOffsetFromNumber(ServerRequestInterface $request, int $limit)

No description

static int
extractOffset(ServerRequestInterface $request, int|null $limit = 0)

No description

static array
extractInclude(ServerRequestInterface $request, array|null $available)

No description

static array
extractFilter(ServerRequestInterface $request)

No description

static array
extractFields(ServerRequestInterface $request, array|null $available = null)

No description

Details

static bool isApiRequest(ServerRequestInterface $request)

Determine if the request is an API request. We do not manually set the `Accepts` header for API requests, so we need to check the priority list to determine whether it is or not.

Normal browsing requests will have `text/html` as their preferred content type, while API will have `* / *`.

Parameters

ServerRequestInterface $request

Return Value

bool

static bool isHtmlRequest(ServerRequestInterface $request)

Parameters

ServerRequestInterface $request

Return Value

bool

static string getPreferredContentType(ServerRequestInterface $request, array $types)

Determine the client's preferred content type out of the given list.

Parameters

ServerRequestInterface $request
array $types The content types to check against, in order of priority. The best match will be returned.

Return Value

string The best matching type, or an empty string if none could be determined.

static User getActor(ServerRequestInterface $request)

Parameters

ServerRequestInterface $request

Return Value

User

static ServerRequestInterface withActor(ServerRequestInterface $request, User $actor)

Parameters

ServerRequestInterface $request
User $actor

Return Value

ServerRequestInterface

static array|null extractSort(ServerRequestInterface $request, string|null $default, array $available = [])

Parameters

ServerRequestInterface $request
string|null $default
array $available

Return Value

array|null

static int|null extractLimit(ServerRequestInterface $request, int|null $defaultLimit = null, int|null $max = null)

Parameters

ServerRequestInterface $request
int|null $defaultLimit
int|null $max

Return Value

int|null

static int extractOffsetFromNumber(ServerRequestInterface $request, int $limit)

Parameters

ServerRequestInterface $request
int $limit

Return Value

int

static int extractOffset(ServerRequestInterface $request, int|null $limit = 0)

Parameters

ServerRequestInterface $request
int|null $limit

Return Value

int

static array extractInclude(ServerRequestInterface $request, array|null $available)

Parameters

ServerRequestInterface $request
array|null $available

Return Value

array

static array extractFilter(ServerRequestInterface $request)

Parameters

ServerRequestInterface $request

Return Value

array

static array extractFields(ServerRequestInterface $request, array|null $available = null)

Parameters

ServerRequestInterface $request
array|null $available

Return Value

array