mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Additional interface for {@link SS_List} classes that are sortable.
|
|
*
|
|
* All methods in this interface are immutable - they should return new instances with the sort
|
|
* applied, rather than applying the sort in place
|
|
*
|
|
* @see SS_List, SS_Filterable, SS_Limitable
|
|
*/
|
|
interface SS_Sortable {
|
|
|
|
/**
|
|
* Returns TRUE if the list can be sorted by a field.
|
|
*
|
|
* @param string $by
|
|
* @return bool
|
|
*/
|
|
public function canSortBy($by);
|
|
|
|
/**
|
|
* Sorts this list by one or more fields. You can either pass in a single
|
|
* field name and direction, or a map of field names to sort directions.
|
|
*
|
|
* @example $list = $list->sort('Name'); // default ASC sorting
|
|
* @example $list = $list->sort('Name DESC'); // DESC sorting
|
|
* @example $list = $list->sort('Name', 'ASC');
|
|
* @example $list = $list->sort(array('Name'=>'ASC,'Age'=>'DESC'));
|
|
*/
|
|
public function sort();
|
|
|
|
|
|
/**
|
|
* Reverses the list based on reversing the current sort.
|
|
*
|
|
* @example $list = $list->reverse();
|
|
*
|
|
* @return array
|
|
*/
|
|
public function reverse();
|
|
}
|