Turba_List
in package
implements
Countable
The Turba_List:: class provides an interface for dealing with a list of Turba_Objects.
Copyright 2000-2017 Horde LLC (http://www.horde.org/)
See the enclosed file LICENSE for license information (ASL). If you did did not receive this file, see http://www.horde.org/licenses/apache.
Tags
Interfaces, Classes, Traits and Enums
- Countable
Table of Contents
- $objects : array<string|int, mixed>
- The array containing the Turba_Objects represented in this list.
- $_usortCriteria : iteratable<string|int, mixed>
- The field to compare objects by.
- __construct() : mixed
- Constructor.
- count() : int
- filter() : Turba_List
- Returns a filtered list of objects.
- insert() : mixed
- Inserts a new object into the list.
- next() : Turba_Object
- Returns the next Turba_Object in the list. Use this to hide internal implementation details from client objects.
- reset() : Turba_Object
- Resets our internal pointer to the beginning of the list. Use this to hide the internal storage (array, list, etc.) from client objects.
- sort() : mixed
- Filters/Sorts the list based on the specified sort routine.
- _cmp() : int
- Usort helper function.
Properties
$objects
The array containing the Turba_Objects represented in this list.
public
array<string|int, mixed>
$objects
= array()
$_usortCriteria
The field to compare objects by.
protected
iteratable<string|int, mixed>
$_usortCriteria
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $ids = array() ]) : mixed
Parameters
- $ids : array<string|int, mixed> = array()
Return values
mixed —count()
public
count() : int
Return values
int —filter()
Returns a filtered list of objects.
public
filter(string $field, array<string|int, mixed> $values) : Turba_List
Parameters
- $field : string
-
The field to filter on.
- $values : array<string|int, mixed>
-
An array of values that $field must be equal to in order to be returned in the filtered list.
Return values
Turba_List —The filtered list object.
insert()
Inserts a new object into the list.
public
insert(Turba_Object $object) : mixed
Parameters
- $object : Turba_Object
-
The object to insert.
Return values
mixed —next()
Returns the next Turba_Object in the list. Use this to hide internal implementation details from client objects.
public
next() : Turba_Object
Return values
Turba_Object —The next object in the list.
reset()
Resets our internal pointer to the beginning of the list. Use this to hide the internal storage (array, list, etc.) from client objects.
public
reset() : Turba_Object
Return values
Turba_Object —The next object in the list.
sort()
Filters/Sorts the list based on the specified sort routine.
public
sort([array<string|int, mixed> $order = null ]) : mixed
The default sort order is by last name, ascending.
Parameters
- $order : array<string|int, mixed> = null
-
Array of hashes describing sort fields. Each hash has the following fields:
ascending - (boolean) Sort direction. field - (string) Sort field.
Return values
mixed —_cmp()
Usort helper function.
protected
_cmp(Turba_Object $a, Turba_Object $b) : int
Compares two Turba_Objects based on the member variable $_usortCriteria, taking care to sort numerically if it is an integer field.
Parameters
- $a : Turba_Object
-
The first Turba_Object to compare.
- $b : Turba_Object
-
The second Turba_Object to compare.
Return values
int —Comparison of the two field values.