51 public function __construct($node, $aggregationKinds=array()) {
53 $this->_nodeList = array();
54 $this->_processedOidList = array();
55 $this->_currentNode = $node;
56 $this->_startNode = $node;
57 $this->_aggregationKinds = $aggregationKinds;
72 public function key() {
73 return $this->_currentNode->getOID()->__toString();
81 $this->_processedOidList[] = $this->_currentNode->getOID()->__toString();
84 $childrenArray = array();
85 $mapper = $this->_currentNode->getMapper();
86 $relations = $mapper->getRelations(
'child');
88 foreach ($relations as $relation) {
89 $aggregationKind = $relation->getOtherAggregationKind();
90 if ($relation->getOtherNavigability() && ($followAll || in_array($aggregationKind, $this->_aggregationKinds))) {
91 $childValue = $this->_currentNode->getValue($relation->getOtherRole());
92 if ($childValue != null) {
93 $children = $relation->isMultiValued() ? $childValue : array($childValue);
94 foreach ($children as $child) {
95 $childrenArray[] = $child;
103 if (
sizeof($this->_nodeList) != 0) {
104 $node = array_pop($this->_nodeList);
105 $oidStr = $node->getOID()->__toString();
107 while (
sizeof($this->_nodeList) > 0 && in_array($oidStr, $this->_processedOidList)) {
108 $node = array_pop($this->_nodeList);
109 $oidStr = $node->getOID()->__toString();
112 if (
sizeof($this->_nodeList) == 0 && in_array($oidStr, $this->_processedOidList)) {
115 $this->_currentNode = $node;
128 $this->_nodeList = array();
129 $this->_processedOidList = array();
145 for ($i=
sizeof($nodeList)-1; $i>=0; $i--) {
146 if ($nodeList[$i] instanceof
Node) {
147 $this->_nodeList[] = $nodeList[$i];
next()
Move forward to next element.
Node related interfaces and classes.
current()
Return the current element.
NodeIterator is used to iterate over a tree/list built of Nodes using a Depth-First-Algorithm.
valid()
Checks if current position is valid.
rewind()
Rewind the Iterator to the first element.
__construct($node, $aggregationKinds=array())
Constructor.
addToQueue($nodeList)
Add nodes to the processing queue.
key()
Return the key of the current element.
Node adds the concept of relations to PersistentObject.