DataSet
Implements DumpableInterface, ArrayAccess, Countable, IteratorDataSet is a collection class that allows the developer to operate on a set of DataObjects as if they were in a typical PHP array.
since |
1.0 |
---|---|
package |
Joomla Framework |
Methods
__call
The magic call method is used to call object methods using the iterator.
__call(string method, array arguments = []) : array
Example: $array = $objectList->foo('bar');
The object list will iterate over its objects and see if each object has a callable 'foo' method. If so, it will pass the argument list and assemble any return values. If an object does not have a callable method no return value is recorded. The keys of the objects and the result array are maintained.
since |
1.0 |
---|
Arguments
- method
string
The name of the method called.- arguments
array
The arguments of the method called.
Response
array
An array of values returned by the methods called on the objects in the data set.
__construct
The class constructor.
__construct(\Joomla\Data\DataObject[] objects = []) : mixed
since |
1.0 |
---|---|
throws |
|
Arguments
- objects
\Joomla\Data\DataObject[]
An array of DataObject objects to bind to the data set.
Response
mixed
__get
The magic get method is used to get a list of properties from the objects in the data set.
__get(string property) : array
Example: $array = $dataSet->foo;
This will return a column of the values of the 'foo' property in all the objects (or values determined by custom property setters in the individual DataObject's). The result array will contain an entry for each object in the list (compared to __call which may not). The keys of the objects and the result array are maintained.
since |
1.0 |
---|
Arguments
- property
string
The name of the data property.
Response
array
An associative array of the values.
__isset
The magic isset method is used to check the state of an object property using the iterator.
__isset(string property) : bool
Example: $array = isset($objectList->foo);
since |
1.0 |
---|
Arguments
- property
string
The name of the property.
Response
bool
True if the property is set in any of the objects in the data set.
__set
The magic set method is used to set an object property using the iterator.
__set(string property, mixed value) : void
Example: $objectList->foo = 'bar';
This will set the 'foo' property to 'bar' in all of the objects (or a value determined by custom property setters in the DataObject).
since |
1.0 |
---|
Arguments
- property
string
The name of the property.- value
mixed
The value to give the data property.
__unset
The magic unset method is used to unset an object property using the iterator.
__unset(string property) : void
Example: unset($objectList->foo);
This will unset all of the 'foo' properties in the list of DataObject's.
since |
1.0 |
---|
Arguments
- property
string
The name of the property.
clear
Clears the objects in the data set.
clear() : \Joomla\Data\DataSet
since |
1.0 |
---|
Response
\Joomla\Data\DataSet
Returns itself to allow chaining.
count
Gets the number of data objects in the set.
count() : int
since |
1.0 |
---|
Response
int
The number of objects.
current
Get the current data object in the set.
current() : \Joomla\Data\DataObject|false
since |
1.0 |
---|
Response
\Joomla\Data\DataObject|false
The current object, or false if the array is empty or the pointer is beyond the end of the elements.
dump
Dumps the data object in the set, recursively if appropriate.
dump(int depth = 3, \SplObjectStorage dumped = null) : array
see | DataObject::dump() |
---|---|
since |
1.0 |
Arguments
- depth
int
The maximum depth of recursion (default = 3). For example, a depth of 0 will return a stdClass with all the properties in native form. A depth of 1 will recurse into the first level of properties only.- dumped
\SplObjectStorage
An array of already serialized objects that is used to avoid infinite loops.
Response
array
An associative array of the data objects in the set, dumped as a simple PHP stdClass object.
getObjectsKeys
Gets an array of keys, existing in objects
getObjectsKeys(string type = 'all') : array
since |
1.2.0 |
---|---|
throws |
|
Arguments
- type
string
Selection type 'all' or 'common'
Response
array
Array of keys
initialise
Initialises the list with an array of objects.
initialise(array input = []) : void
since |
1.0 |
---|---|
throws |
|
Arguments
- input
array
An array of objects.
jsonSerialize
Gets the data set in a form that can be serialised to JSON format.
jsonSerialize() : array
Note that this method will not return an associative array, otherwise it would be encoded into an object. JSON decoders do not consistently maintain the order of associative keys, whereas they do maintain the order of arrays.
since |
1.0 |
---|
Response
array
key
Gets the key of the current object in the iterator.
key() : int|false
since |
1.0 |
---|
Response
int|false
The object key on success; false on failure.
keys
Gets the array of keys for all the objects in the iterator (emulates array_keys).
keys() : array
since |
1.0 |
---|
Response
array
The array of keys
next
Advances the iterator to the next object in the iterator.
next() : void
since |
1.0 |
---|
offsetExists
Checks whether an offset exists in the iterator.
offsetExists(mixed offset) : bool
since |
1.0 |
---|
Arguments
- offset
mixed
The object offset.
Response
bool
offsetGet
Gets an offset in the iterator.
offsetGet(mixed offset) : \Joomla\Data\DataObject|null
since |
1.0 |
---|
Arguments
- offset
mixed
The object offset.
Response
\Joomla\Data\DataObject|null
offsetSet
Sets an offset in the iterator.
offsetSet(mixed offset, \Joomla\Data\DataObject object) : void
since |
1.0 |
---|---|
throws |
|
Arguments
- offset
mixed
The object offset.- object
\Joomla\Data\DataObject
The object object.
offsetUnset
Unsets an offset in the iterator.
offsetUnset(mixed offset) : void
since |
1.0 |
---|
Arguments
- offset
mixed
The object offset.
rewind
Rewinds the iterator to the first object.
rewind() : void
since |
1.0 |
---|
toArray
Gets all objects as an array
toArray(bool associative = true, string keys) : array
since |
1.2.0 |
---|
Arguments
- associative
bool
Option to set return mode: associative or numeric array.- keys
string
Unlimited optional property names to extract from objects.
Response
array
Returns an array according to defined options.
valid
Validates the iterator.
valid() : bool
since |
1.0 |
---|
Response
bool
walk
Applies a function to every object in the set (emulates array_walk).
walk(callable funcname) : bool
since |
1.2.0 |
---|---|
throws |
|
Arguments
- funcname
callable
Callback function.
Response
bool
Properties
current
The current position of the iterator.
since |
1.0 |
---|
Type(s)
int
objects
The iterator objects.
since |
1.0 |
---|
Type(s)
\Joomla\Data\DataObject[]