silverstripe-framework/ORM/Sortable.php
Damian Mooyman 8dd644d25d
API Namespace all classes
Namespace all templates
Move difflib and BBCodeParser2 to thirdparty
Remove deprecated API marked for removal in 4.0
2016-09-08 10:23:17 +12:00

44 lines
1.1 KiB
PHP

<?php
namespace SilverStripe\ORM;
/**
* 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 extends SS_List {
/**
* Returns TRUE if the list can be sorted by a field.
*
* @param string $by
* @return bool
*/
public function canSortBy($by);
/**
* Return a new instance of this list that is sorted 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.
*
* @return static
* @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();
/**
* Return a new instance of this list based on reversing the current sort.
*
* @return SS_Sortable
* @example $list = $list->reverse();
*/
public function reverse();
}