Zeta Components Manual :: Docs For Class ezcTreeNodeListIterator
Tree::ezcTreeNodeListIterator
Class ezcTreeNodeListIterator
ezcTreeNodeListIterator implements an iterator over an ezcTreeNodeList.
The iterator is instantiated with both an implementation of an ezcTree and an ezcTreeNodeList object. It can be used to iterate over all the nodes in a list.
Example:
- <?php
- // fetch all the nodes in a subtree as an ezcNodeList
- $nodeList = $tree->fetchSubtree( 'pan' );
- {
- // do something with the node ID and data - data is fetched on
- // demand
- }
- ?>
Data for the nodes in the node lists is fetched on demand, unless the "prefetch" argument is set to true. In that case the iterator will fetch the data when the iterator is instantiated. This reduces the number of queries made for database and persistent object based data stores, but increases memory usage.
Example:
- <?php
- // fetch all the nodes in a subtree as an ezcNodeList
- $nodeList = $tree->fetchSubtree( 'Uranus' );
- // instantiate an iterator with pre-fetching enabled
- {
- // do something with the node ID and data - data is fetched when
- // the iterator is instatiated.
- }
- ?>
Source for this file: /Tree/src/tree_node_list_iterator.php
Implements interfaces:
- Iterator (internal interface)
Version: | //autogentag// |
Method Summary
public ezcTreeNodeListIterator |
__construct(
$tree
, $nodeList
, [ $prefetch
= false] )
Constructs a new ezcTreeNodeListIterator object over $nodeList. |
public mixed |
current(
)
Returns the data belonging to the current node, and fetches the data in case on-demand fetching is required. |
public string |
key(
)
Returns the node ID of the current node. |
public void |
next(
)
Advances the internal pointer to the next node in the nodelist. |
public void |
rewind(
)
Rewinds the internal pointer back to the start of the nodelist. |
public bool |
valid(
)
Returns whether the internal pointer is still valid. |
Methods
__construct
Constructs a new ezcTreeNodeListIterator object over $nodeList.
The $tree argument is used so that data can be fetched on-demand.
Parameters:
Name | Type | Description |
---|---|---|
$tree |
ezcTree | |
$nodeList |
ezcTreeNodeList | |
$prefetch |
bool |
current
Returns the data belonging to the current node, and fetches the data in case on-demand fetching is required.
Implementation of:
Method | Description |
---|---|
Iterator::current |
key
Returns the node ID of the current node.
Implementation of:
Method | Description |
---|---|
Iterator::key |
next
Advances the internal pointer to the next node in the nodelist.
Implementation of:
Method | Description |
---|---|
Iterator::next |
rewind
Rewinds the internal pointer back to the start of the nodelist.
Implementation of:
Method | Description |
---|---|
Iterator::rewind |
valid
Returns whether the internal pointer is still valid.
It returns false when the end of list has been reached.
Implementation of:
Method | Description |
---|---|
Iterator::valid |