Oihana PHP

PrepareSort uses \oihana\traits\SortDefaultTrait

Prepares the `sort` parameter of a controller request.

This trait resolves the sorting expression from the route arguments and lets the request query string override it. When the request supplies a value it is stored in the parameter bag; otherwise the method falls back to the explicit $default and then to the $sortDefault provided by SortDefaultTrait.

Only the query string is inspected (the request body is ignored).

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Methods

prepareSort()  : string|null
Prepares the sorting parameter based on the given request and arguments.

Methods

prepareSort()

Prepares the sorting parameter based on the given request and arguments.

protected prepareSort(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null &$params = null ][, string|null $default = null ][, string $name = ControllerParam::SORT ]) : string|null
Parameters
$request : ServerRequestInterface|null

The request object, which may contain a sorting parameter.

$args : array<string|int, mixed> = []

An associative array of arguments, which may include a predefined sorting value.

$params : array<string|int, mixed>|null = null

A reference to an array where the resolved sorting parameter will be stored.

$default : string|null = null

The fallback sorting expression used when neither the arguments nor the request provide one.

$name : string = ControllerParam::SORT

The name of the sort parameter to read and store (defaults to ControllerParam::SORT).

Return values
string|null

The resolved sorting parameter or the default sorting value if none is provided.

On this page

Search results