2012-03-09 02:28:14 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Additional interface for {@link SS_List} classes that are sortable.
|
2012-07-20 04:51:12 +02:00
|
|
|
*
|
|
|
|
* All methods in this interface are immutable - they should return new instances with the sort
|
|
|
|
* applied, rather than applying the sort in place
|
|
|
|
*
|
2012-03-09 02:28:14 +01:00
|
|
|
* @see SS_List, SS_Filterable, SS_Limitable
|
2013-11-29 05:12:47 +01:00
|
|
|
* @package framework
|
|
|
|
* @subpackage model
|
2012-03-09 02:28:14 +01:00
|
|
|
*/
|
2014-07-30 01:07:01 +02:00
|
|
|
interface SS_Sortable extends SS_List {
|
2012-03-09 02:28:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns TRUE if the list can be sorted by a field.
|
|
|
|
*
|
|
|
|
* @param string $by
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function canSortBy($by);
|
|
|
|
|
|
|
|
/**
|
2012-12-12 05:22:45 +01:00
|
|
|
* Return a new instance of this list that is sorted by one or more fields. You can either pass in a single
|
2012-03-09 02:28:14 +01:00
|
|
|
* field name and direction, or a map of field names to sort directions.
|
|
|
|
*
|
2012-12-12 05:22:45 +01:00
|
|
|
* @return SS_Sortable
|
2012-07-20 04:51:12 +02:00
|
|
|
* @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'));
|
2012-03-09 02:28:14 +01:00
|
|
|
*/
|
|
|
|
public function sort();
|
2014-07-30 01:07:01 +02:00
|
|
|
|
|
|
|
|
2012-04-15 10:34:10 +02:00
|
|
|
/**
|
2012-12-12 05:22:45 +01:00
|
|
|
* Return a new instance of this list based on reversing the current sort.
|
2012-04-15 10:34:10 +02:00
|
|
|
*
|
2012-12-12 05:22:45 +01:00
|
|
|
* @return SS_Sortable
|
2012-07-20 04:51:12 +02:00
|
|
|
* @example $list = $list->reverse();
|
2012-04-15 10:34:10 +02:00
|
|
|
*/
|
|
|
|
public function reverse();
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|