Joomla CMS
4.2.2
Documentation des API du CMS Joomla en version 4.2.2
|
Fonctions membres publiques | |
__construct (array $objects=[]) | |
__call ($method, $arguments=[]) | |
__get ($property) | |
__isset ($property) | |
__set ($property, $value) | |
__unset ($property) | |
getObjectsKeys ($type='all') | |
toArray ($associative=true,... $keys) | |
count () | |
clear () | |
current () | |
dump ($depth=3, \SplObjectStorage $dumped=null) | |
jsonSerialize () | |
key () | |
keys () | |
walk (callable $funcname) | |
next () | |
offsetExists ($offset) | |
offsetGet ($offset) | |
offsetSet ($offset, $object) | |
offsetUnset ($offset) | |
rewind () | |
valid () | |
Fonctions membres privées | |
initialise (array $input=[]) | |
Attributs privés | |
$current = false | |
$objects = [] | |
DataSet is a collection class that allows the developer to operate on a set of DataObjects as if they were in a typical PHP array.
__construct | ( | array | $objects = [] | ) |
The class constructor.
DataObject[] | $objects An array of DataObject objects to bind to the data set. |
Références DataSet\$objects, et DataSet\initialise().
__call | ( | $method, | |
$arguments = [] |
|||
) |
The magic call method is used to call object methods using the iterator.
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.
string | $method | The name of the method called. |
array | $arguments | The arguments of the method called. |
__get | ( | $property | ) |
The magic get method is used to get a list of properties from the objects in the data set.
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.
string | $property | The name of the data property. |
__isset | ( | $property | ) |
The magic isset method is used to check the state of an object property using the iterator.
Example: $array = isset($objectList->foo);
string | $property | The name of the property. |
Références $return.
__set | ( | $property, | |
$value | |||
) |
The magic set method is used to set an object property using the iterator.
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).
string | $property | The name of the property. |
mixed | $value | The value to give the data property. |
Références $value.
__unset | ( | $property | ) |
The magic unset method is used to unset an object property using the iterator.
Example: unset($objectList->foo);
This will unset all of the 'foo' properties in the list of DataObject's.
string | $property | The name of the property. |
clear | ( | ) |
Clears the objects in the data set.
Références $this, et DataSet\rewind().
count | ( | ) |
Gets the number of data objects in the set.
current | ( | ) |
Get the current data object in the set.
Références DataSet\$current.
dump | ( | $depth = 3 , |
|
\SplObjectStorage | $dumped = null |
||
) |
Dumps the data object in the set, recursively if appropriate.
integer | $depth | 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. |
\SplObjectStorage | $dumped | An array of already serialized objects that is used to avoid infinite loops. |
Implémente DumpableInterface.
Références $key, DataSet\$objects, $this, et null.
getObjectsKeys | ( | $type = 'all' | ) |
Gets an array of keys, existing in objects
string | $type | Selection type 'all' or 'common' |
Références $function, $type, elseif, et null.
Référencé par DataSet\toArray().
|
private |
Initialises the list with an array of objects.
array | $input | An array of objects. |
Références $input, $key, $this, null, et DataSet\rewind().
Référencé par DataSet\__construct().
jsonSerialize | ( | ) |
Gets the data set in a form that can be serialised to JSON format.
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.
Références $return.
key | ( | ) |
Gets the key of the current object in the iterator.
Références DataSet\$current.
keys | ( | ) |
Gets the array of keys for all the objects in the iterator (emulates array_keys).
Référencé par DataSet\next(), DataSet\offsetUnset(), et DataSet\rewind().
next | ( | ) |
Advances the iterator to the next object in the iterator.
Références $position, DataSet\keys(), et null.
offsetExists | ( | $offset | ) |
Checks whether an offset exists in the iterator.
mixed | $offset | The object offset. |
Références Joomla\Database\Query\$offset.
offsetGet | ( | $offset | ) |
Gets an offset in the iterator.
mixed | $offset | The object offset. |
Références Joomla\Database\Query\$offset, et null.
offsetSet | ( | $offset, | |
$object | |||
) |
Sets an offset in the iterator.
mixed | $offset | The object offset. |
DataObject | $object | The object object. |
Références Joomla\Database\Query\$offset, class, et null.
offsetUnset | ( | $offset | ) |
Unsets an offset in the iterator.
mixed | $offset | The object offset. |
Références Joomla\Database\Query\$offset, $position, $this, et DataSet\keys().
rewind | ( | ) |
Rewinds the iterator to the first object.
Références DataSet\keys().
Référencé par DataSet\clear(), et DataSet\initialise().
toArray | ( | $associative = true , |
|
$keys | |||
) |
Gets all objects as an array
boolean | $associative | Option to set return mode: associative or numeric array. |
string | ...$keys Unlimited optional property names to extract from objects. |
Références $i, $key, $return, DataSet\getObjectsKeys(), et null.
valid | ( | ) |
Validates the iterator.
walk | ( | callable | $funcname | ) |
Applies a function to every object in the set (emulates array_walk).
callable | $funcname | Callback function. |
Références $key.
Référencé par DataSet\current(), et DataSet\key().
|
private |
Référencé par DataSet\__construct(), et DataSet\dump().