Sort
class Sort (View source)
| internal | JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it. |
Gathers information about the sort parameter.
Constants
| KEY_NAME |
The JSON:API sort key name. |
| PATH_KEY |
The field key in the sort parameter: sort[lorem][ |
| DIRECTION_KEY |
The direction key in the sort parameter: sort[lorem][ |
| LANGUAGE_KEY |
The langcode key in the sort parameter: sort[lorem][ |
Properties
| protected string | $fields | The fields on which to sort. |
Methods
Constructs a new Sort object.
Gets the root condition group.
Creates a Sort object from a query parameter.
Expands a simple string sort into a more expressive sort that we can use.
Expands a sort item in case a shortcut was used.
Details
__construct(array $fields)
Constructs a new Sort object.
Takes an array of sort fields. Example: [ [ 'path' => 'changed', 'direction' => 'DESC', ], [ 'path' => 'title', 'direction' => 'ASC', 'langcode' => 'en-US', ], ]
fields()
Gets the root condition group.
static Sort
createFromQueryParameter(mixed $parameter)
Creates a Sort object from a query parameter.
static protected array
expandFieldString(string $fields)
Expands a simple string sort into a more expressive sort that we can use.
static protected array
expandItem(array $sort_item)
Expands a sort item in case a shortcut was used.