Detailed Description

NodeIterator is used to iterate over a tree/list built of Nodes using a Depth-First-Algorithm.

Classes used with the NodeIterator must implement the getChildren() and getOID() methods.

The following example shows the usage:

// load the node with depth 10
$node = ObjectFactory::getInstance('persistenceFacade')->load(new ObjectId('Page', 300), 10);
// iterate over all children
$it = new NodeIterator($node);
foreach($it as $oid => $obj) {
echo("current object id: ".$oid);
echo("current object: ".$obj);
}
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 36 of file NodeIterator.php.

+ Inheritance diagram for NodeIterator:

Public Member Functions

 __construct ($node, $aggregationKinds=[])
 
 current ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 

Protected Member Functions

 addToQueue ($nodeList)
 

Protected Attributes

 $end
 
 $nodeList
 
 $processedOidList
 
 $currentNode
 
 $startNode
 
 $aggregationKinds
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $node,
  $aggregationKinds = [] 
)

Constructor.

Parameters
$nodeThe node to start from.
$aggregationKindsArray of aggregation kind values of relations to follow possible values: 'none', 'shared', 'composite'. Empty array means all (default: empty)

Definition at line 51 of file NodeIterator.php.

Member Function Documentation

◆ current()

current ( )

Return the current element.

Returns
Node instance

Definition at line 64 of file NodeIterator.php.

◆ key()

key ( )

Return the key of the current element.

Returns
String, the serialized object id

Definition at line 72 of file NodeIterator.php.

◆ next()

next ( )

Move forward to next element.

Definition at line 79 of file NodeIterator.php.

◆ rewind()

rewind ( )

Rewind the Iterator to the first element.

Definition at line 126 of file NodeIterator.php.

◆ valid()

valid ( )

Checks if current position is valid.

Definition at line 136 of file NodeIterator.php.

◆ addToQueue()

addToQueue (   $nodeList)
protected

Add nodes to the processing queue.

Parameters
$nodeListAn array of nodes.

Definition at line 144 of file NodeIterator.php.

Member Data Documentation

◆ $end

$end
protected

Definition at line 38 of file NodeIterator.php.

◆ $nodeList

$nodeList
protected

Definition at line 39 of file NodeIterator.php.

◆ $processedOidList

$processedOidList
protected

Definition at line 40 of file NodeIterator.php.

◆ $currentNode

$currentNode
protected

Definition at line 41 of file NodeIterator.php.

◆ $startNode

$startNode
protected

Definition at line 42 of file NodeIterator.php.

◆ $aggregationKinds

$aggregationKinds
protected

Definition at line 43 of file NodeIterator.php.

static getInstance($name, $dynamicConfiguration=[])