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 JData
+ Graphe d'héritage de JData:
+ Graphe de collaboration de JData:

Liste de tous les membres

Fonctions membres publiques

 __construct ($properties=array())
 __get ($property)
 __isset ($property)
 __set ($property, $value)
 __unset ($property)
 bind ($properties, $updateNulls=true)
 dump ($depth=3, SplObjectStorage $dumped=null)
 getIterator ()
 jsonSerialize ()
 count ()

Fonctions membres protégées

 dumpProperty ($property, $depth, SplObjectStorage $dumped)
 getProperty ($property)
 setProperty ($property, $value)

Attributs privés

 $_properties = array()

Description détaillée

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


Documentation des constructeurs et destructeur

JData::__construct (   $properties = array())

The class constructor.

Paramètres:
mixed$propertiesEither an associative array or another object by which to set the initial properties of the new object.
Depuis:
12.3
Exceptions:
InvalidArgumentException

Définition à la ligne 39 du fichier data.php.

{
// Check the properties input.
if (!empty($properties))
{
// Bind the properties.
$this->bind($properties);
}
}

Documentation des fonctions membres

JData::__get (   $property)

The magic get method is used to get a data property.

This method is a public proxy for the protected getProperty method.

Note: Magic __get does not allow recursive calls. This can be tricky because the error generated by recursing into __get is "Undefined property: {CLASS}::{PROPERTY}" which is misleading. This is relevant for this class because requesting a non-visible property can trigger a call to a sub-function. If that references the property directly in the object, it will cause a recursion into __get.

Paramètres:
string$propertyThe name of the data property.
Renvoie:
mixed The value of the data property, or null if the data property does not exist.
Voir également:
JData::getProperty()
Depuis:
12.3

Définition à la ligne 66 du fichier data.php.

{
return $this->getProperty($property);
}
JData::__isset (   $property)

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

Paramètres:
string$propertyThe name of the data property.
Renvoie:
boolean True if set, otherwise false is returned.
Depuis:
12.3

Définition à la ligne 80 du fichier data.php.

{
return isset($this->_properties[$property]);
}
JData::__set (   $property,
  $value 
)

The magic set method is used to set a data property.

This is a public proxy for the protected setProperty method.

Paramètres:
string$propertyThe name of the data property.
mixed$valueThe value to give the data property.
Renvoie:
void
Voir également:
JData::setProperty()
Depuis:
12.3

Définition à la ligne 98 du fichier data.php.

{
$this->setProperty($property, $value);
}
JData::__unset (   $property)

The magic unset method is used to unset a data property.

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

Définition à la ligne 112 du fichier data.php.

{
unset($this->_properties[$property]);
}
JData::bind (   $properties,
  $updateNulls = true 
)

Binds an array or object to this object.

Paramètres:
mixed$propertiesAn associative array of properties or an object.
boolean$updateNullsTrue to bind null values, false to ignore null values.
Renvoie:
JData Returns itself to allow chaining.
Depuis:
12.3
Exceptions:
InvalidArgumentException

Définition à la ligne 128 du fichier data.php.

{
// Check the properties data type.
if (!is_array($properties) && !is_object($properties))
{
throw new InvalidArgumentException(sprintf('%s(%s)', __METHOD__, gettype($properties)));
}
// Check if the object is traversable.
if ($properties instanceof Traversable)
{
// Convert iterator to array.
$properties = iterator_to_array($properties);
}
// Check if the object needs to be converted to an array.
elseif (is_object($properties))
{
// Convert properties to an array.
$properties = (array) $properties;
}
// Bind the properties.
foreach ($properties as $property => $value)
{
// Check if the value is null and should be bound.
if ($value === null && !$updateNulls)
{
continue;
}
// Set the property.
$this->setProperty($property, $value);
}
return $this;
}
JData::count ( )

Count the number of data properties.

Renvoie:
integer The number of data properties.
Depuis:
12.3

Définition à la ligne 328 du fichier data.php.

{
return count($this->_properties);
}
JData::dump (   $depth = 3,
SplObjectStorage  $dumped = null 
)

Dumps the data properties into a stdClass object, 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:
stdClass The data properties as a simple PHP stdClass object.
Depuis:
12.3

Implémente JDataDumpable.

Définition à la ligne 177 du fichier data.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);
// Setup a container.
$dump = new stdClass;
// Dump all object properties.
foreach (array_keys($this->_properties) as $property)
{
// Get the property.
$dump->$property = $this->dumpProperty($property, $depth, $dumped);
}
return $dump;
}
JData::dumpProperty (   $property,
  $depth,
SplObjectStorage  $dumped 
)
protected

Dumps a data property.

If recursion is set, this method will dump any object implementing JDumpable (like JData and JDataSet); it will convert a JDate object to a string; and it will convert a JRegistry to an object.

Paramètres:
string$propertyThe name of the data property.
integer$depthThe current depth of recursion (a value of 0 will ignore recursion).
SplObjectStorage$dumpedAn array of already serialized objects that is used to avoid infinite loops.
Renvoie:
mixed The value of the dumped property.
Depuis:
12.3

Définition à la ligne 242 du fichier data.php.

{
$value = $this->getProperty($property);
if ($depth > 0)
{
// Check if the object is also an dumpable object.
if ($value instanceof JDataDumpable)
{
// Do not dump the property if it has already been dumped.
if (!$dumped->contains($value))
{
$value = $value->dump($depth - 1, $dumped);
}
}
// Check if the object is a date.
if ($value instanceof JDate)
{
$value = (string) $value;
}
// Check if the object is a registry.
elseif ($value instanceof JRegistry)
{
$value = $value->toObject();
}
}
return $value;
}
JData::getIterator ( )

Gets this object represented as an ArrayIterator.

This allows the data properties to be access via a foreach statement.

Renvoie:
ArrayIterator This object represented as an ArrayIterator.
Voir également:
IteratorAggregate::getIterator()
Depuis:
12.3

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

{
return new ArrayIterator($this->dump(0));
}
JData::getProperty (   $property)
protected

Gets a data property.

Paramètres:
string$propertyThe name of the data property.
Renvoie:
mixed The value of the data property.
Voir également:
JData::__get()
Depuis:
12.3

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

{
// Get the raw value.
$value = array_key_exists($property, $this->_properties) ? $this->_properties[$property] : null;
return $value;
}
JData::jsonSerialize ( )

Gets the data properties in a form that can be serialised to JSON format.

Renvoie:
string An object that can be serialised by json_encode().
Depuis:
12.3

Implémente JsonSerializable.

Définition à la ligne 223 du fichier data.php.

{
return $this->dump();
}
JData::setProperty (   $property,
  $value 
)
protected

Sets a data property.

If the name of the property starts with a null byte, this method will return null.

Paramètres:
string$propertyThe name of the data property.
mixed$valueThe value to give the data property.
Renvoie:
mixed The value of the data property.
Voir également:
JData::__set()
Depuis:
12.3

Définition à la ligne 304 du fichier data.php.

{
/*
* Check if the property starts with a null byte. If so, discard it because a later attempt to try to access it
* can cause a fatal error. See http://us3.php.net/manual/en/language.types.array.php#language.types.array.casting
*/
if (strpos($property, "\0") === 0)
{
return null;
}
// Set the value.
$this->_properties[$property] = $value;
return $value;
}

Documentation des données membres

JData::$_properties = array()
private

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


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