PrepareOrder uses trait:short
Prepares the `order` (sort direction) parameter of a controller request.
This trait reads the ControllerParam::ORDER value from the request and validates
it, uppercased, against the whitelist of accepted directions declared in the controller
api configuration (ControllerParam::ORDERS). A recognized value is assigned to
the referenced $order variable and mirrored into the parameter bag.
Tags
Table of Contents
Properties
- $api : array<string|int, mixed>
- The default api settings.
Methods
- initializeApi() : static
- Initializes the internal `api` settings.
- prepareOrder() : void
- Prepares the `order` direction from the request.
Properties
$api
The default api settings.
protected
array<string|int, mixed>
$api
= []
Methods
initializeApi()
Initializes the internal `api` settings.
public
initializeApi([array<string|int, mixed> $init = [] ][, ContainerInterface|null $container = null ]) : static
By default, this method search in the DI container a ControllerParam::API definition to initialize the "api" property.
Parameters
- $init : array<string|int, mixed> = []
-
Optional initialization array (e.g., ['api' => [ ... ] ] ).
- $container : ContainerInterface|null = null
-
Optional DI container for retrieving the 'api' array representation.
Tags
Return values
static —Returns the current controller instance for method chaining.
prepareOrder()
Prepares the `order` direction from the request.
protected
prepareOrder(ServerRequestInterface|null $request, array<string|int, mixed>|null &$params, mixed &$order) : void
Parameters
- $request : ServerRequestInterface|null
-
The incoming PSR-7 server request, or null when no request context is available.
- $params : array<string|int, mixed>|null
-
A reference to the parameter bag updated in place with the resolved order direction.
- $order : mixed
-
A reference to the order holder assigned in place when the request supplies an accepted direction.