class SortsField in Search API sorts 8
A value object for a sorts field.
Hierarchy
- class \Drupal\search_api_sorts\SortsField
Expanded class hierarchy of SortsField
2 files declare their use of SortsField
- search_api_sorts_test_hook.module in tests/
search_api_sorts_test_hook/ search_api_sorts_test_hook.module - Tests all the hooks.
- SortsFieldTest.php in tests/
src/ Unit/ SortsFieldTest.php
File
- src/
SortsField.php, line 8
Namespace
Drupal\search_api_sortsView source
class SortsField {
/**
* The field of the sorting.
*
* @var string $field
*/
protected $field;
/**
* The direction of the sorting.
*
* @var string $order
*/
protected $order;
/**
* Constructs an instance of the value object.
*
* @param string $field
* The field to sort on.
* @param string $order
* The direction to sort on.
*/
public function __construct($field, $order = NULL) {
$this
->setFieldName($field);
$this
->setOrder($order);
}
/**
* Overrides the field to sort on.
*
* @param string $field
* The field of sorting.
*/
public function setFieldName($field) {
$this->field = $field;
}
/**
* Returns the field to sort on.
*
* @return string
* The field of sorting.
*/
public function getFieldName() {
return $this->field;
}
/**
* Overrides the order to sort on.
*
* @param string $order
* The direction of the sorting.
*/
public function setOrder($order) {
$this->order = $order == 'desc' ? 'desc' : 'asc';
}
/**
* Returns the direction of sorting, asc or desc.
*
* @return string
* The direction of the sorting.
*/
public function getOrder() {
return $this->order;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SortsField:: |
protected | property | The field of the sorting. | |
SortsField:: |
protected | property | The direction of the sorting. | |
SortsField:: |
public | function | Returns the field to sort on. | |
SortsField:: |
public | function | Returns the direction of sorting, asc or desc. | |
SortsField:: |
public | function | Overrides the field to sort on. | |
SortsField:: |
public | function | Overrides the order to sort on. | |
SortsField:: |
public | function | Constructs an instance of the value object. |