Detailed Description

PersistentIterator is used to iterate over a tree/list built of persistent objects using a Depth-First-Algorithm.

To persist its state use the PersistentIterator::save() method, to restore its state use the static PersistentIterator::load() method, which returns the loaded instance.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 24 of file PersistentIterator.php.

+ Inheritance diagram for PersistentIterator:

Public Member Functions

 __construct ($id, PersistenceFacade $persistenceFacade, Session $session, ObjectId $oid, $aggregationKinds=[])
 
 save ()
 
 current ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 

Static Public Member Functions

static reset ($id, Session $session)
 
static load ($id, $persistenceFacade, $session)
 

Protected Member Functions

 addToQueue ($oidList, $depth)
 

Protected Attributes

 $end
 
 $oidList
 
 $processedOidList
 
 $currentOid
 
 $startOid
 
 $currentDepth
 
 $aggregationKinds
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $id,
PersistenceFacade  $persistenceFacade,
Session  $session,
ObjectId  $oid,
  $aggregationKinds = [] 
)

Constructor.

Parameters
$idThe unique iterator id used to store iterator's the state in the session
$persistenceFacade
$session
$oidThe object id 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 47 of file PersistentIterator.php.

Member Function Documentation

◆ save()

save ( )

Save the iterator state to the session.

Definition at line 68 of file PersistentIterator.php.

◆ reset()

static reset (   $id,
Session  $session 
)
static

Reset the iterator with the given id.

Parameters
$idThe iterator id
$session

Definition at line 79 of file PersistentIterator.php.

◆ load()

static load (   $id,
  $persistenceFacade,
  $session 
)
static

Load an iterator state from the session.

Parameters
$idThe unique iterator id used to store iterator's the state in the session
$persistenceFacade
$session
Returns
PersistentIterator instance holding the saved state or null if unique id is not found

Definition at line 90 of file PersistentIterator.php.

◆ current()

current ( )

Return the current element.

Returns
ObjectId, the current object id

Definition at line 111 of file PersistentIterator.php.

◆ key()

key ( )

Return the key of the current element.

Returns
Number, the current depth

Definition at line 119 of file PersistentIterator.php.

◆ next()

next ( )

Move forward to next element.

Definition at line 126 of file PersistentIterator.php.

◆ rewind()

rewind ( )

Rewind the Iterator to the first element.

Definition at line 176 of file PersistentIterator.php.

◆ valid()

valid ( )

Checks if current position is valid.

Definition at line 187 of file PersistentIterator.php.

◆ addToQueue()

addToQueue (   $oidList,
  $depth 
)
protected

Add object ids to the processing queue.

Parameters
$oidListAn array of object ids.
$depthThe depth of the object ids in the tree.

Definition at line 196 of file PersistentIterator.php.

Member Data Documentation

◆ $end

$end
protected

Definition at line 30 of file PersistentIterator.php.

◆ $oidList

$oidList
protected

Definition at line 31 of file PersistentIterator.php.

◆ $processedOidList

$processedOidList
protected

Definition at line 32 of file PersistentIterator.php.

◆ $currentOid

$currentOid
protected

Definition at line 33 of file PersistentIterator.php.

◆ $startOid

$startOid
protected

Definition at line 34 of file PersistentIterator.php.

◆ $currentDepth

$currentDepth
protected

Definition at line 35 of file PersistentIterator.php.

◆ $aggregationKinds

$aggregationKinds
protected

Definition at line 36 of file PersistentIterator.php.