OrderFilter

Allows to change default ordering of collection responses.

Syntax: ?order[property]=<asc|desc>

It is possible to order by single field (query string ?order[title]=asc) or by multiple of them (query string ?order[title]=asc&order[datetime]=desc).

It may happen that conflict of names will occur if order is also the name of property with enabled another filter. Solution in such cases would be a change of parameter name used by OrderFilter. It can be done using argument orderParameterName, as on example below:

use SourceBroker\T3api\Annotation as T3api;
use SourceBroker\T3api\Filter\OrderFilter;

/**
 * @T3api\ApiResource (
 *     collectionOperations={
 *          "get"={
 *              "path"="/news/news",
 *          },
 *     },
 * )
 *
 * @T3api\ApiFilter(
 *     OrderFilter::class,
 *     properties={"title","datetime"}
 *     arguments={"orderParameterName": "myOrderParameterName"},
 * )
 */
 class News extends \GeorgRinger\News\Domain\Model\News
{
}
Copied!