Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JDataSet
+ Graphe d'héritage de JDataSet:
+ Graphe de collaboration de JDataSet:

Liste de tous les membres

Fonctions membres publiques

 __construct (array $objects=array())
 __call ($method, $arguments=array())
 __get ($property)
 __isset ($property)
 __set ($property, $value)
 __unset ($property)
 count ()
 clear ()
 current ()
 dump ($depth=3, SplObjectStorage $dumped=null)
 jsonSerialize ($serialized=null)
 key ()
 keys ()
 next ()
 offsetExists ($offset)
 offsetGet ($offset)
 offsetSet ($offset, $object)
 offsetUnset ($offset)
 rewind ()
 valid ()

Fonctions membres privées

 _initialise (array $input=array())

Attributs privés

 $_current = false
 $_objects = array()

Description détaillée

Définition à la ligne 20 du fichier set.php.


Documentation des constructeurs et destructeur

JDataSet::__construct ( array  $objects = array())

The class constructor.

Paramètres:
array$objectsAn array of JData objects to bind to the data set.
Depuis:
12.3
Exceptions:
InvalidArgumentExceptionif an object is not an instance of JData.

Définition à la ligne 46 du fichier set.php.

{
// Set the objects.
$this->_initialise($objects);
}

Documentation des fonctions membres

JDataSet::__call (   $method,
  $arguments = array() 
)

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.

Paramètres:
string$methodThe name of the method called.
array$argumentsThe arguments of the method called.
Renvoie:
array An array of values returned by the methods called on the objects in the data set.
Depuis:
12.3

Définition à la ligne 69 du fichier set.php.

{
$return = array();
// Iterate through the objects.
foreach ($this->_objects as $key => $object)
{
// Create the object callback.
$callback = array($object, $method);
// Check if the callback is callable.
if (is_callable($callback))
{
// Call the method for the object.
$return[$key] = call_user_func_array($callback, $arguments);
}
}
return $return;
}
JDataSet::__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 JData'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.

Paramètres:
string$propertyThe name of the data property.
Renvoie:
array An associative array of the values.
Depuis:
12.3

Définition à la ligne 106 du fichier set.php.

{
$return = array();
// Iterate through the objects.
foreach ($this->_objects as $key => $object)
{
// Get the property.
$return[$key] = $object->$property;
}
return $return;
}
JDataSet::__isset (   $property)

The magic isset method is used to check the state of an object property using the iterator.

Example: $array = isset($objectList->foo);

Paramètres:
string$propertyThe name of the property.
Renvoie:
boolean True if the property is set in any of the objects in the data set.
Depuis:
12.3

Définition à la ligne 131 du fichier set.php.

{
$return = array();
// Iterate through the objects.
foreach ($this->_objects as $object)
{
// Check the property.
$return[] = isset($object->$property);
}
return in_array(true, $return, true) ? true : false;
}
JDataSet::__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 JData).

Paramètres:
string$propertyThe name of the property.
mixed$valueThe value to give the data property.
Renvoie:
void
Depuis:
12.3

Définition à la ligne 160 du fichier set.php.

{
// Iterate through the objects.
foreach ($this->_objects as $object)
{
// Set the property.
$object->$property = $value;
}
}
JDataSet::__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 JData's.

Paramètres:
string$propertyThe name of the property.
Renvoie:
void
Depuis:
12.3

Définition à la ligne 183 du fichier set.php.

{
// Iterate through the objects.
foreach ($this->_objects as $object)
{
unset($object->$property);
}
}
JDataSet::_initialise ( array  $input = array())
private

Initialises the list with an array of objects.

Paramètres:
array$inputAn array of objects.
Renvoie:
void
Depuis:
12.3
Exceptions:
InvalidArgumentExceptionif an object is not an instance of JData.

Définition à la ligne 506 du fichier set.php.

{
foreach ($input as $key => $object)
{
if (!is_null($object))
{
$this->offsetSet($key, $object);
}
}
$this->rewind();
}
JDataSet::clear ( )

Clears the objects in the data set.

Renvoie:
JDataSet Returns itself to allow chaining.
Depuis:
12.3

Définition à la ligne 211 du fichier set.php.

{
$this->_objects = array();
$this->rewind();
return $this;
}
JDataSet::count ( )

Gets the number of data objects in the set.

Renvoie:
integer The number of objects.
Depuis:
12.3

Définition à la ligne 199 du fichier set.php.

{
return count($this->_objects);
}
JDataSet::current ( )

Get the current data object in the set.

Renvoie:
JData The current object, or false if the array is empty or the pointer is beyond the end of the elements.
Depuis:
12.3

Définition à la ligne 226 du fichier set.php.

{
return is_scalar($this->_current) ? $this->_objects[$this->_current] : false;
}
JDataSet::dump (   $depth = 3,
SplObjectStorage  $dumped = null 
)

Dumps the data object in the set, recursively if appropriate.

Paramètres:
integer$depthThe 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$dumpedAn array of already serialized objects that is used to avoid infinite loops.
Renvoie:
array An associative array of the date objects in the set, dumped as a simple PHP stdClass object.
Voir également:
JData::dump()
Depuis:
12.3

Implémente JDataDumpable.

Définition à la ligne 244 du fichier set.php.

{
// Check if we should initialise the recursion tracker.
if ($dumped === null)
{
$dumped = new SplObjectStorage;
}
// Add this object to the dumped stack.
$dumped->attach($this);
$objects = array();
// Make sure that we have not reached our maximum depth.
if ($depth > 0)
{
// Handle JSON serialization recursively.
foreach ($this->_objects as $key => $object)
{
$objects[$key] = $object->dump($depth, $dumped);
}
}
return $objects;
}
JDataSet::jsonSerialize (   $serialized = null)

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.

Paramètres:
mixed$serializedAn array of objects that have already been serialized that is used to infinite loops (null on first call).
Renvoie:
array An array that can be serialised by json_encode().
Depuis:
12.3

Définition à la ligne 283 du fichier set.php.

{
// Check if we should initialise the recursion tracker.
if ($serialized === null)
{
$serialized = array();
}
// Add this object to the serialized stack.
$serialized[] = spl_object_hash($this);
$return = array();
// Iterate through the objects.
foreach ($this->_objects as $object)
{
// Call the method for the object.
$return[] = $object->jsonSerialize($serialized);
}
return $return;
}
JDataSet::key ( )

Gets the key of the current object in the iterator.

Renvoie:
scalar The object key on success; null on failure.
Depuis:
12.3

Définition à la ligne 312 du fichier set.php.

{
}
JDataSet::keys ( )

Gets the array of keys for all the objects in the iterator (emulates array_keys).

Renvoie:
array The array of keys
Depuis:
12.3

Définition à la ligne 324 du fichier set.php.

{
return array_keys($this->_objects);
}
JDataSet::next ( )

Advances the iterator to the next object in the iterator.

Renvoie:
void
Depuis:
12.3

Définition à la ligne 336 du fichier set.php.

{
// Get the object offsets.
$keys = $this->keys();
// Check if _current has been set to false but offsetUnset.
if ($this->_current === false && isset($keys[0]))
{
// This is a special case where offsetUnset was used in a foreach loop and the first element was unset.
$this->_current = $keys[0];
}
else
{
// Get the current key.
$position = array_search($this->_current, $keys);
// Check if there is an object after the current object.
if ($position !== false && isset($keys[$position + 1]))
{
// Get the next id.
$this->_current = $keys[$position + 1];
}
else
{
// That was the last object or the internal properties have become corrupted.
$this->_current = null;
}
}
}
JDataSet::offsetExists (   $offset)

Checks whether an offset exists in the iterator.

Paramètres:
mixed$offsetThe object offset.
Renvoie:
boolean True if the object exists, false otherwise.
Depuis:
12.3

Définition à la ligne 375 du fichier set.php.

{
return isset($this->_objects[$offset]);
}
JDataSet::offsetGet (   $offset)

Gets an offset in the iterator.

Paramètres:
mixed$offsetThe object offset.
Renvoie:
JData The object if it exists, null otherwise.
Depuis:
12.3

Définition à la ligne 389 du fichier set.php.

{
return isset($this->_objects[$offset]) ? $this->_objects[$offset] : null;
}
JDataSet::offsetSet (   $offset,
  $object 
)

Sets an offset in the iterator.

Paramètres:
mixed$offsetThe object offset.
JData$objectThe object object.
Renvoie:
void
Depuis:
12.3
Exceptions:
InvalidArgumentExceptionif an object is not an instance of JData.

Définition à la ligne 405 du fichier set.php.

{
// Check if the object is a JData object.
if (!($object instanceof JData))
{
throw new InvalidArgumentException(sprintf('%s("%s", *%s*)', __METHOD__, $offset, gettype($object)));
}
// Set the offset.
$this->_objects[$offset] = $object;
}
JDataSet::offsetUnset (   $offset)

Unsets an offset in the iterator.

Paramètres:
mixed$offsetThe object offset.
Renvoie:
void
Depuis:
12.3

Définition à la ligne 426 du fichier set.php.

{
if (!$this->offsetExists($offset))
{
// Do nothing if the offset does not exist.
return;
}
// Check for special handling of unsetting the current position.
if ($offset == $this->_current)
{
// Get the current position.
$keys = $this->keys();
$position = array_search($this->_current, $keys);
// Check if there is an object before the current object.
if ($position > 0)
{
// Move the current position back one.
$this->_current = $keys[$position - 1];
}
else
{
// We are at the start of the keys AND let's assume we are in a foreach loop and `next` is going to be called.
$this->_current = false;
}
}
unset($this->_objects[$offset]);
}
JDataSet::rewind ( )

Rewinds the iterator to the first object.

Renvoie:
void
Depuis:
12.3

Définition à la ligne 464 du fichier set.php.

{
// Set the current position to the first object.
if (empty($this->_objects))
{
$this->_current = false;
}
else
{
$keys = $this->keys();
$this->_current = array_shift($keys);
}
}
JDataSet::valid ( )

Validates the iterator.

Renvoie:
boolean True if valid, false otherwise.
Depuis:
12.3

Définition à la ligne 485 du fichier set.php.

{
// Check the current position.
if (!is_scalar($this->_current) || !isset($this->_objects[$this->_current]))
{
return false;
}
return true;
}

Documentation des données membres

JDataSet::$_current = false
private

Définition à la ligne 28 du fichier set.php.

JDataSet::$_objects = array()
private

Définition à la ligne 36 du fichier set.php.


La documentation de cette classe a été générée à partir du fichier suivant :