Dojo/Data.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Dojo  
Version
$Id$  

\Zend_Dojo_Data

Package: Zend_Dojo
dojo.data support for Zend Framework
Implements
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Uses
 
Uses
 
Uses
 

Properties

>VPropertyprotectedstring|int $_identifier
Identifier field of item
Details
Type
string | int
>VPropertyprotectedarray $_items = array()
Collected items
Default valuearray()Details
Type
array
>VPropertyprotectedstring $_label
Label field of item
Details
Type
string
>VPropertyprotectedarray $_metadata = array()
Data container metadata
Default valuearray()Details
Type
array

Methods

methodpublic__construct(string | null $identifier = null, array | \Traversable | null $items = null, string | null $label = null) : void

Constructor

Parameters
NameTypeDescription
$identifierstring | null
$itemsarray | \Traversable | null
$labelstring | null
methodpublic__toString() : string

Serialize to string (proxy to {@link toJson()})

Returns
TypeDescription
string
methodprotected_normalizeItem(array | object $item, string | int | null $id) : array

Normalize an item to attach to the collection

Parameters
NameTypeDescription
$itemarray | object
$idstring | int | null
Returns
TypeDescription
array
methodpublicaddItem(array | object $item, string | null $id = null) : \Zend_Dojo_Data

Add an individual item, optionally by identifier

Parameters
NameTypeDescription
$itemarray | object
$idstring | null
Returns
TypeDescription
\Zend_Dojo_Data
methodpublicaddItems(array | \Traversable $items) : \Zend_Dojo_Data

Add multiple items at once

Parameters
NameTypeDescription
$itemsarray | \Traversable
Returns
TypeDescription
\Zend_Dojo_Data
methodpublicclearItems() : \Zend_Dojo_Data

Remove all items at once

Returns
TypeDescription
\Zend_Dojo_Data
methodpublicclearMetadata(null | string $key = null) : \Zend_Dojo_Data

Clear individual or all metadata item(s)

Parameters
NameTypeDescription
$keynull | string
Returns
TypeDescription
\Zend_Dojo_Data
methodpubliccount() : int

Countable: how many items are present

Returns
TypeDescription
int
methodpubliccurrent() : array

Iterator: get current value

Returns
TypeDescription
array
methodpublicfromArray(array $data) : \Zend_Dojo_Data

Load object from array

Parameters
NameTypeDescription
$dataarray
Returns
TypeDescription
\Zend_Dojo_Data
methodpublicfromJson(string $json) : \Zend_Dojo_Data

Load object from JSON

Parameters
NameTypeDescription
$jsonstring
Returns
TypeDescription
\Zend_Dojo_Data
methodpublicgetIdentifier() : string | int | null

Retrieve current item identifier

Returns
TypeDescription
string | int | null
methodpublicgetItem(string $id) : array

Retrieve an item by identifier

Item retrieved will be flattened to an array.
Parameters
NameTypeDescription
$idstring
Returns
TypeDescription
array
methodpublicgetItems() : array

Get all items as an array

Serializes items to arrays.
Returns
TypeDescription
array
methodpublicgetLabel() : string | null

Retrieve item association label

Returns
TypeDescription
string | null
methodpublicgetMetadata(null | string $key = null) : mixed

Get metadata item or all metadata

Parameters
NameTypeDescription
$keynull | string

Metadata key when pulling single metadata item

Returns
TypeDescription
mixed
methodpublichasItem(string | int $id) : bool

Does an item with the given identifier exist?

Parameters
NameTypeDescription
$idstring | int
Returns
TypeDescription
bool
methodpublickey() : string | int

Iterator: get current key

Returns
TypeDescription
string | int
methodpublicnext() : void

Iterator: get next item

methodpublicoffsetExists(string | int $offset) : bool

ArrayAccess: does offset exist?

Parameters
NameTypeDescription
$offsetstring | int
Returns
TypeDescription
bool
methodpublicoffsetGet(string | int $offset) : array

ArrayAccess: retrieve by offset

Parameters
NameTypeDescription
$offsetstring | int
Returns
TypeDescription
array
methodpublicoffsetSet(string $offset, array | object | null $value) : void

ArrayAccess: set value by offset

Parameters
NameTypeDescription
$offsetstring
$valuearray | object | null
methodpublicoffsetUnset(string $offset) : void

ArrayAccess: unset value by offset

Parameters
NameTypeDescription
$offsetstring
methodpublicremoveItem(string $id) : \Zend_Dojo_Data

Remove item by identifier

Parameters
NameTypeDescription
$idstring
Returns
TypeDescription
\Zend_Dojo_Data
methodpublicrewind() : void

Iterator: rewind to first value in collection

methodpublicsetIdentifier(string | int | null $identifier) : \Zend_Dojo_Data

Set identifier for item lookups

Parameters
NameTypeDescription
$identifierstring | int | null
Returns
TypeDescription
\Zend_Dojo_Data
methodpublicsetItem(array | object $item,  $id = null) : \Zend_Dojo_Data

Set an individual item, optionally by identifier (overwrites)

Parameters
NameTypeDescription
$itemarray | object
$id
Returns
TypeDescription
\Zend_Dojo_Data
methodpublicsetItems(array | \Traversable $items) : \Zend_Dojo_Data

Set the items to collect

Parameters
NameTypeDescription
$itemsarray | \Traversable
Returns
TypeDescription
\Zend_Dojo_Data
methodpublicsetLabel(string | null $label) : \Zend_Dojo_Data

Set label to use for displaying item associations

Parameters
NameTypeDescription
$labelstring | null
Returns
TypeDescription
\Zend_Dojo_Data
methodpublicsetMetadata(string | array $spec, mixed $value = null) : \Zend_Dojo_Data

Set metadata by key or en masse

Parameters
NameTypeDescription
$specstring | array
$valuemixed
Returns
TypeDescription
\Zend_Dojo_Data
methodpublictoArray() : array

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

Returns
TypeDescription
array
methodpublictoJson() : string

Serialize to JSON (dojo.data format)

Returns
TypeDescription
string
methodpublicvalid() : bool

Iterator: is item valid?

Returns
TypeDescription
bool
Documentation was generated by phpDocumentor 2.2.0 .