PrepareFacets uses trait:short
Prepares the facet definitions of a controller request.
This trait merges the facets carried by the route arguments with two request-driven
sources: the per-parameter facet definitions declared in the controller params
mapping (see prepareParamsFacets()), and a raw JSON facets query parameter.
Each contributing query value is URL-encoded and recorded in the parameter bag, while
invalid JSON is logged as a warning and ignored.
Tags
Table of Contents
Properties
- $params : array<string|int, mixed>|null
- The default parameters definition.
Methods
- initializeParams() : static
- Initializes the params definition from an array.
- prepareFacets() : array<string|int, mixed>|null
- Prepares and returns the facet definitions.
- prepareParamsFacets() : void
- Try to creates the facets definition with the $this->params array definition of the controller.
Properties
$params
The default parameters definition.
public
array<string|int, mixed>|null
$params
= null
Methods
initializeParams()
Initializes the params definition from an array.
public
initializeParams([array<string|int, mixed> $init = [] ]) : static
Parameters
- $init : array<string|int, mixed> = []
-
Initialization array, read from the ControllerParam::PARAMS key.
Return values
static —Returns the current instance for method chaining.
prepareFacets()
Prepares and returns the facet definitions.
protected
prepareFacets(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null &$params = [] ]) : 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 an initial set of facets.
- $params : array<string|int, mixed>|null = []
-
A reference to the parameter bag updated in place with the URL-encoded facet payloads.
Return values
array<string|int, mixed>|null —The merged facet definitions.
prepareParamsFacets()
Try to creates the facets definition with the $this->params array definition of the controller.
protected
prepareParamsFacets(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, array<string|int, mixed> &$facets = [] ][, array<string|int, mixed>|null &$params = [] ]) : void
Target all 'facets' definitions.
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, optionally carrying a ControllerParam::PARAMS mapping.
- $facets : array<string|int, mixed> = []
-
A reference to the facet collection enriched in place from the matching query parameters.
- $params : array<string|int, mixed>|null = []
-
A reference to the parameter bag updated in place with the URL-encoded facet payloads.