DataSet
Implements \Joomla\Data\DumpableInterface, \ArrayAccess, \Countable, \IteratorDataSet is a collection class that allows the developer to operate on a set of DataObject objects as if they were in a typical PHP array.
since |
1.0 |
---|
Methods
__call
The magic call method is used to call object methods using the iterator.
__call(string $method, array $arguments = array()) : 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(array<mixed,\Joomla\Data\DataObject> $objects = array())
since |
1.0 |
---|---|
throws |
|
Arguments
- $objects
array<mixed,\Joomla\Data\DataObject>
An array of DataObject objects to bind to the data set.
__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 Data\Object'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) : boolean
Example: $array = isset($objectList->foo);
since |
1.0 |
---|
Arguments
- $property
string
The name of the property.
Response
boolean
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 Data\Object).
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 Data\Object's.
since |
1.0 |
---|
Arguments
- $property
string
The name of the property.
_initialise
Initialises the list with an array of objects.
_initialise(array $input = array()) : void
since |
1.0 |
---|---|
throws |
|
Arguments
- $input
array
An array of objects.
clear
Clears the objects in the data set.
clear() : \Joomla\Data\DataSet
count
Gets the number of data objects in the set.
count() : integer
since |
1.0 |
---|
Response
integer
The number of objects.
current
Get the current data object in the set.
current() : \Joomla\Data\DataObject
since |
1.0 |
---|
Response
\Joomla\Data\DataObject
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(integer $depth = 3, \SplObjectStorage $dumped = null) : array
see | \Joomla\Data\DataObject::dump() |
---|---|
since |
1.0 |
Arguments
- $depth
integer
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
jsonSerialize
Gets the data set in a form that can be serialised to JSON format.
jsonSerialize(mixed $serialized = null) : 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 |
---|
Arguments
- $serialized
mixed
An array of objects that have already been serialized that is used to infinite loops (null on first call).
Response
array
An array that can be serialised by json_encode().
key
Gets the key of the current object in the iterator.
key() : scalar
since |
1.0 |
---|
Response
scalar
The object key on success; null 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) : boolean
since |
1.0 |
---|
Arguments
- $offset
mixed
The object offset.
Response
boolean
True if the object exists, false otherwise.
offsetGet
Gets an offset in the iterator.
offsetGet(mixed $offset) : \Joomla\Data\DataObject
since |
1.0 |
---|
Arguments
- $offset
mixed
The object offset.
Response
\Joomla\Data\DataObject
The object if it exists, null otherwise.
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(boolean $associative = true, string $k = null) : array
since |
1.2.0 |
---|
Arguments
- $associative
boolean
Option to set return mode: associative or numeric array.- $k
string
Unlimited optional property names to extract from objects.
Response
array
Returns an array according to defined options.
valid
Validates the iterator.
valid() : boolean
since |
1.0 |
---|
Response
boolean
True if valid, false otherwise.
walk
Applies a function to every object in the set (emulates array_walk).
walk(callable $funcname) : boolean
since |
1.2.0 |
---|---|
throws |
|
Arguments
- $funcname
callable
Callback function.
Response
boolean
Properties
current
The current position of the iterator.
since |
1.0 |
---|
Type(s)
integer