Oihana PHP

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
author

Marc Alcaraz (ekameleon)

since
1.0.0

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
throws
NotFoundExceptionInterface

If the container is used and the 'api' definition is not found in the DI container.

ContainerExceptionInterface

If the container throws an internal error.

RuntimeException

If no valid App instance is provided or found.

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.

Tags
throws
NotFoundException

If the underlying parameter resolution fails to locate a required dependency.

On this page

Search results