Helper to walk multi-dimensional collections. More...
Static Public Member Functions | |
static | walkCollection ($collection, $dimension, $render_function, $on_enter=null, $on_leave=null, $depth=0, &$collection_key=null) |
Walk multi-dimensional collection. More... | |
static | walkCollectionWithTarget ($collection, &$target, $dimension, $render_function, $on_enter=null, $on_leave=null, $depth=0, &$collection_key=null) |
Walk multi-dimensional collection and keep reference to parallel collection. More... | |
Helper to walk multi-dimensional collections.
|
static |
Walk multi-dimensional collection.
This method is designed for use with anonymous functions with binded variables (use
keyword). Other way would be to pass variables via method arguments and it means to specify them three times, which is not very practical.
Trees are not supported. But if tree nodes are given in list, it is possible to indent them manually.
$render_function
.$collection | is the collection to walk. |
$dimension | is amount of dimensions to traverse (0 = single item, 1 = list, 2 = matrix, ...). |
$render_function | is function($collection_key, $item) called for each item in collection. |
$on_enter | is function($depth) called when going deeper. |
$on_leave | is function($depth) called when going back. |
$depth | is for internal use, leave it unspecified. |
$collection_key | is for internal use, leave it unspecified. |
|
static |
Walk multi-dimensional collection and keep reference to parallel collection.
Just like walkCollection(), but $target
parameter is walked in parallel, which means the $target_item
reference points to the same position as $item
, but in $target
structure.
$collection | is the collection to walk. |
$dimension | is amount of dimensions to traverse (0 = single item, 1 = list, 2 = matrix, ...). |
$render_function | is function($collection_key, $item, $target_item) called for each item in collection. |
$on_enter | is function($depth) called when going deeper. |
$on_leave | is function($depth) called when going back. |
$depth | is for internal use, leave it unspecified. |
$collection_key | is for internal use, leave it unspecified. |