SS_List
interface SS_List implements ArrayAccess, Countable, IteratorAggregate (View source)
An interface that a class can implement to be treated as a list container.
Methods
Adds an item to the list, making no guarantees about where it will appear.
Returns a map of a key field to a value field of all the items in the list.
Returns the first item in the list where the key field is equal to the value.
Returns an array of a single field value for all items in the list.
Returns a unique array of a single field value for all items in the list.
Returns TRUE if the list can be filtered by a given field expression.
Return a new instance of this list that only includes items with these characteristics
Return a copy of this list which contains items matching any of these characteristics.
Return a new instance of this list that excludes any items with these characteristics
Return a copy of this list which does not contain any items with any of these params
Return a new instance of this list that excludes any items with these characteristics Filter this List by a callback function. The function will be passed each record of the List in turn, and must return true for the record to be included. Returns the filtered list.
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.
Details
array
toArray()
Returns all the items in the list in an array.
array
toNestedArray()
Returns the contents of the list as an array of maps.
void
add(mixed $item)
Adds an item to the list, making no guarantees about where it will appear.
remove(mixed $item)
Removes an item from the list.
Note that a return type is not specified on the interface as different impelementations have different return types.
mixed
first()
Returns the first item in the list.
mixed
last()
Returns the last item in the list.
Map
map(string $keyfield = 'ID', string $titlefield = 'Title')
Returns a map of a key field to a value field of all the items in the list.
mixed
find(string $key, mixed $value)
Returns the first item in the list where the key field is equal to the value.
array
column(string $colName = "ID")
Returns an array of a single field value for all items in the list.
array
columnUnique(string $colName = 'ID')
Returns a unique array of a single field value for all items in the list.
SS_List
each(callable $callback)
Walks the list using the specified callback
bool
canFilterBy(string $by)
Returns TRUE if the list can be filtered by a given field expression.
bool
exists()
Returns true if this list has items
SS_List
filter(...$args)
Return a new instance of this list that only includes items with these characteristics
SS_List
filterAny(...$args)
Return a copy of this list which contains items matching any of these characteristics.
SS_List
exclude(...$args)
Return a new instance of this list that excludes any items with these characteristics
SS_List
excludeAny(...$args)
Return a copy of this list which does not contain any items with any of these params
SS_List
filterByCallback(callable $callback)
Return a new instance of this list that excludes any items with these characteristics Filter this List by a callback function. The function will be passed each record of the List in turn, and must return true for the record to be included. Returns the filtered list.
mixed
byID(mixed $id)
Return the first item with the given ID
SS_List
byIDs(array $ids)
Filter this list to only contain the given Primary IDs
bool
canSortBy(string $by)
Returns TRUE if the list can be sorted by a field.
SS_List
sort(...$args)
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.
SS_List
reverse()
Return a new instance of this list based on reversing the current sort.
SS_List
limit(int|null $length, int $offset = 0)
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.
If $length
is null, then no limit is applied. If $length
is 0, then an empty list is returned.