Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Dojo_Data Class Reference

Public Member Functions

 __construct ($identifier=null, $items=null, $label=null)
 Constructor.
 
 setItems ($items)
 Set the items to collect.
 
 setItem ($item, $id=null)
 Set an individual item, optionally by identifier (overwrites)
 
 addItem ($item, $id=null)
 Add an individual item, optionally by identifier.
 
 addItems ($items)
 Add multiple items at once.
 
 getItems ()
 Get all items as an array.
 
 hasItem ($id)
 Does an item with the given identifier exist?
 
 getItem ($id)
 Retrieve an item by identifier.
 
 removeItem ($id)
 Remove item by identifier.
 
 clearItems ()
 Remove all items at once.
 
 setIdentifier ($identifier)
 Set identifier for item lookups.
 
 getIdentifier ()
 Retrieve current item identifier.
 
 setLabel ($label)
 Set label to use for displaying item associations.
 
 getLabel ()
 Retrieve item association label.
 
 setMetadata ($spec, $value=null)
 Set metadata by key or en masse.
 
 getMetadata ($key=null)
 Get metadata item or all metadata.
 
 clearMetadata ($key=null)
 Clear individual or all metadata item(s)
 
 fromArray (array $data)
 Load object from array.
 
 fromJson ($json)
 Load object from JSON.
 
 toArray ()
 Seralize entire data structure, including identifier and label, to array.
 
 toJson ()
 Serialize to JSON (dojo.data format)
 
 __toString ()
 Serialize to string (proxy to toJson())
 
 offsetExists ($offset)
 ArrayAccess: does offset exist?
 
 offsetGet ($offset)
 ArrayAccess: retrieve by offset.
 
 offsetSet ($offset, $value)
 ArrayAccess: set value by offset.
 
 offsetUnset ($offset)
 ArrayAccess: unset value by offset.
 
 current ()
 Iterator: get current value.
 
 key ()
 Iterator: get current key.
 
 next ()
 Iterator: get next item.
 
 rewind ()
 Iterator: rewind to first value in collection.
 
 valid ()
 Iterator: is item valid?
 
 count ()
 Countable: how many items are present.
 

Protected Member Functions

 _normalizeItem ($item, $id)
 Normalize an item to attach to the collection.
 

Protected Attributes

 $_identifier
 
 $_items = array()
 
 $_label
 
 $_metadata = array()
 

Constructor & Destructor Documentation

__construct (   $identifier = null,
  $items = null,
  $label = null 
)

Constructor.

Parameters
string | null$identifier
array | Traversable | null$items
string | null$label
Returns
void

Member Function Documentation

__toString ( )

Serialize to string (proxy to toJson())

Returns
string
_normalizeItem (   $item,
  $id 
)
protected

Normalize an item to attach to the collection.

Parameters
array | object$item
string | int | null$id
Returns
array
addItem (   $item,
  $id = null 
)

Add an individual item, optionally by identifier.

Parameters
array | object$item
string | null$id
Returns
Zend_Dojo_Data
addItems (   $items)

Add multiple items at once.

Parameters
array | Traversable$items
Returns
Zend_Dojo_Data
clearItems ( )

Remove all items at once.

Returns
Zend_Dojo_Data
clearMetadata (   $key = null)

Clear individual or all metadata item(s)

Parameters
null | string$key
Returns
Zend_Dojo_Data
count ( )

Countable: how many items are present.

Returns
int
current ( )

Iterator: get current value.

Returns
array
fromArray ( array  $data)

Load object from array.

Parameters
array$data
Returns
Zend_Dojo_Data
fromJson (   $json)

Load object from JSON.

Parameters
string$json
Returns
Zend_Dojo_Data
getIdentifier ( )

Retrieve current item identifier.

Returns
string|int|null
getItem (   $id)

Retrieve an item by identifier.

Item retrieved will be flattened to an array.

Parameters
string$id
Returns
array
getItems ( )

Get all items as an array.

Serializes items to arrays.

Returns
array
getLabel ( )

Retrieve item association label.

Returns
string|null
getMetadata (   $key = null)

Get metadata item or all metadata.

Parameters
null | string$keyMetadata key when pulling single metadata item
Returns
mixed
hasItem (   $id)

Does an item with the given identifier exist?

Parameters
string | int$id
Returns
bool
key ( )

Iterator: get current key.

Returns
string|int
next ( )

Iterator: get next item.

Returns
void
offsetExists (   $offset)

ArrayAccess: does offset exist?

Parameters
string | int$offset
Returns
bool
offsetGet (   $offset)

ArrayAccess: retrieve by offset.

Parameters
string | int$offset
Returns
array
offsetSet (   $offset,
  $value 
)

ArrayAccess: set value by offset.

Parameters
string$offset
array | object | null$value
Returns
void
offsetUnset (   $offset)

ArrayAccess: unset value by offset.

Parameters
string$offset
Returns
void
removeItem (   $id)

Remove item by identifier.

Parameters
string$id
Returns
Zend_Dojo_Data
rewind ( )

Iterator: rewind to first value in collection.

Returns
void
setIdentifier (   $identifier)

Set identifier for item lookups.

Parameters
string | int | null$identifier
Returns
Zend_Dojo_Data
setItem (   $item,
  $id = null 
)

Set an individual item, optionally by identifier (overwrites)

Parameters
array | object$item
string | null$identifier
Returns
Zend_Dojo_Data
setItems (   $items)

Set the items to collect.

Parameters
array | Traversable$items
Returns
Zend_Dojo_Data
setLabel (   $label)

Set label to use for displaying item associations.

Parameters
string | null$label
Returns
Zend_Dojo_Data
setMetadata (   $spec,
  $value = null 
)

Set metadata by key or en masse.

Parameters
string | array$spec
mixed$value
Returns
Zend_Dojo_Data
toArray ( )

Seralize entire data structure, including identifier and label, to array.

Returns
array
toJson ( )

Serialize to JSON (dojo.data format)

Returns
string
valid ( )

Iterator: is item valid?

Returns
bool

Member Data Documentation

$_identifier
protected
$_items = array()
protected
$_label
protected
$_metadata = array()
protected