Filterable
interface Filterable implements SS_List
Additional interface for {@link SS_List} classes that are filterable.
All methods in this interface are immutable - they should return new instances with the filter applied, rather than applying the filter in place
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 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 charactaristics
Return a copy of this list which contains items matching any of these charactaristics.
Return a new instance of this list that excludes any items with these charactaristics
Return a new instance of this list that excludes any items with these charactaristics 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 the first item with the given ID
Details
in SS_List at line 20
array
toArray()
Returns all the items in the list in an array.
in SS_List at line 27
array
toNestedArray()
Returns the contents of the list as an array of maps.
in SS_List at line 35
add(mixed $item)
Adds an item to the list, making no guarantees about where it will appear.
in SS_List at line 42
remove(mixed $item)
Removes an item from the list.
in SS_List at line 49
mixed
first()
Returns the first item in the list.
in SS_List at line 56
mixed
last()
Returns the last item in the list.
in SS_List at line 66
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.
in SS_List at line 76
mixed
find(string $key, mixed $value)
Returns the first item in the list where the key field is equal to the value.
in SS_List at line 84
array
column(string $colName = "ID")
Returns an array of a single field value for all items in the list.
in SS_List at line 92
$this
each(callable $callback)
Walks the list using the specified callback
at line 22
bool
canFilterBy(string $by)
Returns TRUE if the list can be filtered by a given field expression.
at line 35
Filterable
filter()
Return a new instance of this list that only includes items with these charactaristics
at line 59
Filterable
filterAny()
Return a copy of this list which contains items matching any of these charactaristics.
at line 72
Filterable
exclude()
Return a new instance of this list that excludes any items with these charactaristics
at line 83
Filterable
filterByCallback(callable $callback)
Return a new instance of this list that excludes any items with these charactaristics 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.
at line 91
mixed
byID(int $id)
Return the first item with the given ID
at line 99
SS_List
byIDs(array $ids)
Filter this list to only contain the given Primary IDs