JOOMLA中国
  • Joomla中国首页
  • 社区
  • 教程
  • 应用市场
  • B计划
Joomla! Framework TM
  • Namespace
  • Class
  • Tree
  • Deprecated

Namespaces

  • Composer
    • Autoload
  • Joomla
    • Application
      • Cli
        • Output
          • Processor
      • Web
    • Data
    • DI
      • Exception
    • Event
    • Filter
    • Input
    • Ldap
    • Registry
      • Format
    • Session
      • Storage
    • String
    • Uri
    • Utilities
  • None
  • PasswordCompat
    • binary
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Yaml
        • Exception
    • Polyfill
      • Util

Classes

  • DataObject
  • DataSet

Interfaces

  • DumpableInterface

Class DataSet

DataSet 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.

Joomla\Data\DataSet implements Joomla\Data\DumpableInterface, ArrayAccess, Countable, Iterator
Namespace: Joomla\Data
Since: 1.0
Located at vendor/joomla/data/src/DataSet.php

Methods summary

public
# __construct( array $objects = array() )

The class constructor.

The class constructor.

Parameters

$objects
Joomla\Data\DataObject[] - $objects An array of DataObject objects to bind to the data set.

Throws

InvalidArgumentException - if an object is not an instance of Data\Object.

Since

1.0
public array
# __call( string $method, array $arguments = array() )

The magic call method is used to call object methods using the iterator.

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.

Parameters

$method
string - $method The name of the method called.
$arguments
array - $arguments The arguments of the method called.

Returns

array - An array of values returned by the methods called on the objects in the data set.

Since

1.0
public array
# __get( string $property )

The magic get method is used to get a list of properties from the objects in the data set.

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 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.

Parameters

$property
string - $property The name of the data property.

Returns

array - An associative array of the values.

Since

1.0
public boolean
# __isset( string $property )

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

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

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

Parameters

$property
string - $property The name of the property.

Returns

boolean - True if the property is set in any of the objects in the data set.

Since

1.0
public
# __set( string $property, mixed $value )

The magic set method is used to set an object property using the iterator.

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 Data\Object).

Parameters

$property
string - $property The name of the property.
$value
mixed - $value The value to give the data property.

Since

1.0
public
# __unset( string $property )

The magic unset method is used to unset an object property using the iterator.

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 Data\Object's.

Parameters

$property
string - $property The name of the property.

Since

1.0
public array
# getObjectsKeys( string $type = 'all' )

Gets an array of keys, existing in objects

Gets an array of keys, existing in objects

Parameters

$type
string - $type Selection type 'all' or 'common'

Returns

array - Array of keys

Throws

InvalidArgumentException

Since

1.2.0
public array
# toArray( boolean $associative = true, string $k = null )

Gets all objects as an array

Gets all objects as an array

Parameters

$associative
boolean - $associative Option to set return mode: associative or numeric array.
$k
string - $k Unlimited optional property names to extract from objects.

Returns

array - Returns an array according to defined options.

Since

1.2.0
public integer
# count( )

Gets the number of data objects in the set.

Gets the number of data objects in the set.

Returns

integer - The number of objects.

Since

1.0

Implementation of

Countable::count()
public Joomla\Data\DataSet
# clear( )

Clears the objects in the data set.

Clears the objects in the data set.

Returns

Joomla\Data\DataSet - Returns itself to allow chaining.

Since

1.0
public Joomla\Data\DataObject
# current( )

Get the current data object in the set.

Get the current data object in the set.

Returns

Joomla\Data\DataObject - The current object, or false if the array is empty or the pointer is beyond the end of the elements.

Since

1.0

Implementation of

Iterator::current()
public array
# dump( integer $depth = 3, SplObjectStorage $dumped = null )

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

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

Parameters

$depth
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.
$dumped
SplObjectStorage - $dumped An array of already serialized objects that is used to avoid infinite loops.

Returns

array - An associative array of the data objects in the set, dumped as a simple PHP stdClass object.

Since

1.0

See

Joomla\Data\DataObject::dump()

Implementation of

Joomla\Data\DumpableInterface::dump()
public array
# jsonSerialize( mixed $serialized = null )

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

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.

Parameters

$serialized
mixed - $serialized An array of objects that have already been serialized that is used to infinite loops (null on first call).

Returns

array - An array that can be serialised by json_encode().

Since

1.0
public scalar
# key( )

Gets the key of the current object in the iterator.

Gets the key of the current object in the iterator.

Returns

scalar - The object key on success; null on failure.

Since

1.0

Implementation of

Iterator::key()
public array
# keys( )

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

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

Returns

array - The array of keys

Since

1.0
public boolean
# walk( callable $funcname )

Applies a function to every object in the set (emulates array_walk).

Applies a function to every object in the set (emulates array_walk).

Parameters

$funcname
callable - $funcname Callback function.

Returns

boolean

Throws

InvalidArgumentException

Since

1.2.0
public
# next( )

Advances the iterator to the next object in the iterator.

Advances the iterator to the next object in the iterator.

Since

1.0

Implementation of

Iterator::next()
public boolean
# offsetExists( mixed $offset )

Checks whether an offset exists in the iterator.

Checks whether an offset exists in the iterator.

Parameters

$offset
mixed - $offset The object offset.

Returns

boolean - True if the object exists, false otherwise.

Since

1.0

Implementation of

ArrayAccess::offsetExists()
public Joomla\Data\DataObject
# offsetGet( mixed $offset )

Gets an offset in the iterator.

Gets an offset in the iterator.

Parameters

$offset
mixed - $offset The object offset.

Returns

Joomla\Data\DataObject - The object if it exists, null otherwise.

Since

1.0

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( mixed $offset, Joomla\Data\DataObject $object )

Sets an offset in the iterator.

Sets an offset in the iterator.

Parameters

$offset
mixed - $offset The object offset.
$object
Joomla\Data\DataObject - $object The object object.

Throws

InvalidArgumentException - if an object is not an instance of Data\Object.

Since

1.0

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( mixed $offset )

Unsets an offset in the iterator.

Unsets an offset in the iterator.

Parameters

$offset
mixed - $offset The object offset.

Since

1.0

Implementation of

ArrayAccess::offsetUnset()
public
# rewind( )

Rewinds the iterator to the first object.

Rewinds the iterator to the first object.

Since

1.0

Implementation of

Iterator::rewind()
public boolean
# valid( )

Validates the iterator.

Validates the iterator.

Returns

boolean - True if valid, false otherwise.

Since

1.0

Implementation of

Iterator::valid()

Magic methods summary

Joomla! Framework TM API documentation generated by ApiGen 2.8.0
Joomla!® and Joomla! Framework™ are trademarks of Open Source Matters, Inc. in the United States and other countries.