PrepareFilter
Prepares the `filter` parameter of a controller request.
This trait expects the ControllerParam::FILTER query parameter to be a JSON
encoded object or list. When it is valid, the decoded structure is returned and the raw
JSON string is recorded in the parameter bag. A filter that cannot be read — not JSON,
or JSON that is neither an object nor a list — is refused with an Error400:
ignoring it would answer the whole, unfiltered collection as if it were the filtered one.
An absent or empty parameter, or the JSON null, means "no filter": the route argument
value (or null) is returned instead.
Tags
Table of Contents
Methods
- prepareFilter() : array<string|int, mixed>|null
- Prepares and returns the `filter` parameter.
Methods
prepareFilter()
Prepares and returns the `filter` parameter.
protected
prepareFilter(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null &$params = null ]) : array<string|int, mixed>|null
Parameters
- $request : ServerRequestInterface|null
-
The incoming PSR-7 server request, or null when no request context is available.
- $args : array<string|int, mixed> = []
-
The route/controller arguments that may carry a fallback
filtervalue. - $params : array<string|int, mixed>|null = null
-
A reference to the parameter bag updated in place with the raw JSON filter string.
Tags
Return values
array<string|int, mixed>|null —The decoded filter definition, or the fallback argument value when no filter is provided.