mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-29 22:16:01 +02:00
In 3.0 there was some confusion about whether DataLists and ArrayLists were mutable or not. If DataLists were immutable, they'd return the result, and your code would look like $list = $list->filter(....); If DataLists were mutable, they'd operate on themselves, returning nothing, and your code would look like $list->filter(....); This makes all DataLists and ArrayList immutable for all _searching_ operations. Operations on DataList that modify the underlying SQL data store remain mutating. - These functions no longer mutate the existing object, and if you do not capture the value returned by them will have no effect: ArrayList#reverse ArrayList#sort ArrayList#filter ArrayList#exclude DataList#dataQuery (use DataList#alterDataQuery to modify dataQuery in a safe manner) DataList#where DataList#limit DataList#sort DataList#addFilter DataList#applyFilterContext DataList#innerJoin DataList#leftJoin DataList#find DataList#byIDs DataList#reverse - DataList#setDataQueryParam has been added as syntactic sugar around the most common cause of accessing the dataQuery directly - setting query parameters - RelationList#setForeignID has been removed. Always use RelationList#forForeignID when querying, and overload RelationList#foreignIDList when subclassing. - Relatedly,the protected variable RelationList->foreignID has been removed, as the ID is now stored on a query parameter. Use RelationList#getForeignID to read it.
23 lines
688 B
PHP
23 lines
688 B
PHP
<?php
|
|
|
|
/**
|
|
* Additional interface for {@link SS_List} classes that are limitable - able to have a subset of the list extracted.
|
|
*
|
|
* All methods in this interface are immutable - they should return new instances with the limit
|
|
* applied, rather than applying the limit in place
|
|
*
|
|
* @see SS_List, SS_Sortable, SS_Filterable
|
|
*/
|
|
interface SS_Limitable {
|
|
|
|
/**
|
|
* Returns a new instance of this list where no more than $limit records are included.
|
|
* If $offset is specified, then that many records at the beginning of the list will be skipped.
|
|
* This matches the behaviour of the SQL LIMIT clause.
|
|
*
|
|
* @return SS_Limitable
|
|
*/
|
|
public function limit($limit, $offset = 0);
|
|
|
|
}
|