- ⌂ collection
- Properties
- Methods
collection Class
- Namespace: io_comand_repo
- Extends: abstract_queryable
- Implements: IteratorAggregate, ArrayAccess, Countable, evaluator, storage_result
A COMAND collection is an ordered list of objects that can be accessed like a standard PHP array. Collections also provide additional information and methods for efficiently working with it's objects.
To access a collection like a standard PHP array, use:
- foreach - Iterate over it's objects with
foreach($collection as $object)
. - count - Count it's objects with
count($collection)
. - indexes - Reference it's objects with an array index, like
$collection[0]
. - append - Append an object to the end of a collection with
$collection[] = $object
. - isset - Check if an object exists at a specific offset with
isset($collection[0])
. - unset - Remove an object from a collection with
unset($collection[0])
.
Example
$num_children = count($collection);
foreach($root->children() as $child) {
echo("$child\n");
}
In addition, a collection also has properties and methods that provide information about the collection's objects, such as content type counts, and functionality to query and manipulate the collection.
Properties
- Repo - Repository queried to retrieve the objects in this collection, and/or the repository where the objects in this collection can be saved.
- Types - Array of associative arrays that contain aggregate information about the types of objects in the collection. KEY=Type->Identifier, VALUE=['Count'=>Integer, 'Type'=>ContentTypeObject] for objects in this collection. This information is generally useful, but is also used by the API internally to help decide how to optimize API queries and other operations.