class Sort in JSON:API 8
Same name and namespace in other branches
- 8.2 src/Query/Sort.php \Drupal\jsonapi\Query\Sort
Gathers information about the sort parameter.
@internal
Hierarchy
- class \Drupal\jsonapi\Query\Sort
Expanded class hierarchy of Sort
6 files declare their use of Sort
- EntityResource.php in src/Controller/ EntityResource.php 
- EntityResourceTest.php in tests/src/ Kernel/ Controller/ EntityResourceTest.php 
- JsonApiParamEnhancer.php in src/Routing/ JsonApiParamEnhancer.php 
- JsonApiParamEnhancerTest.php in tests/src/ Unit/ Routing/ JsonApiParamEnhancerTest.php 
- SortNormalizer.php in src/Normalizer/ SortNormalizer.php 
File
- src/Query/ Sort.php, line 10 
Namespace
Drupal\jsonapi\QueryView source
class Sort {
  /**
   * The JSON API sort key name.
   *
   * @var string
   */
  const KEY_NAME = 'sort';
  /**
   * The field key in the sort parameter: sort[lorem][<field>].
   *
   * @var string
   */
  const PATH_KEY = 'path';
  /**
   * The direction key in the sort parameter: sort[lorem][<direction>].
   *
   * @var string
   */
  const DIRECTION_KEY = 'direction';
  /**
   * The langcode key in the sort parameter: sort[lorem][<langcode>].
   *
   * @var string
   */
  const LANGUAGE_KEY = 'langcode';
  /**
   * The fields on which to sort.
   *
   * @var string
   */
  protected $fields;
  /**
   * Constructs a new Sort object.
   *
   * Takes an array of sort fields. Example:
   *   [
   *     [
   *       'path' => 'changed',
   *       'direction' => 'DESC',
   *     ],
   *     [
   *       'path' => 'title',
   *       'direction' => 'ASC',
   *       'langcode' => 'en-US',
   *     ],
   *   ]
   *
   * @param array $fields
   *   The the entity query sort fields.
   */
  public function __construct(array $fields) {
    $this->fields = $fields;
  }
  /**
   * Gets the root condition group.
   */
  public function fields() {
    return $this->fields;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| Sort:: | protected | property | The fields on which to sort. | |
| Sort:: | constant | The direction key in the sort parameter: sort[lorem][<direction>]. | ||
| Sort:: | public | function | Gets the root condition group. | |
| Sort:: | constant | The JSON API sort key name. | ||
| Sort:: | constant | The langcode key in the sort parameter: sort[lorem][<langcode>]. | ||
| Sort:: | constant | The field key in the sort parameter: sort[lorem][<field>]. | ||
| Sort:: | public | function | Constructs a new Sort object. | 
