API / Minn\Runtime / TreeWalk

TreeWalk final class

Minn\Runtime\TreeWalk · public/minn/src/Minn/Runtime/TreeWalk.php · 182 lines

The Walker contract's traversal: elements keyed by the walker's db_fields parent/id pair, displayed depth-first through the walker's four element methods, whole or a page of top-level elements at a time (probe comment-walker). The facade Walker delegates here; subclasses override the element methods (or display_element itself, as Walker_Comment does to keep replies past the depth limit at their parent's level) and the dispatch stays virtual.

Public

staticwalk(object $walker, array $elements, int $maxDepth, array $args): string#

Walks a tree with a Walker the way the reference does.

$elementslist<object>
staticpage(object $walker, array $elements, int $maxDepth, int $page, int $perPage, array $args): string#

One page of top-level elements, each with its children (paged_walk); no paging when the page is below one or the size negative. Sets the walker's max_pages. Elements whose parent is not in the list are orphans, printed at the top level after the last page's elements; the replies of earlier pages' elements are not orphans.

$elementslist<object>
staticroots(object $walker, array $elements): int#

How many of the elements have no parent. @param list<object> $elements

$elementslist<object>
staticforget(object $walker, mixed $element, array $children): void#

An element's children, and theirs through the walker's unset_children, taken out of the children list.

$childrenarray<int|string, list<object>>
staticelement(object $walker, mixed $element, array $children, int $maxDepth, int $depth, array $args, string $output): void#

Walks one element and its children; replies past the depth limit stay in the list for the walker (or the orphans) to place.

$childrenarray<int|string, mixed>

Internals 3

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatebuckets(object $walker, array $elements, mixed $root = NULL): array#

The top-level elements (no parent, or the parent given) and the others by parent.

$elementslist<object>
@return array{0: list<object>, 1: array<int|string, list<object>>}
privatealone(object $walker, mixed $element, array $args, string $output): void#

One element on its own at the top level: no children, one level shown.

privateorphans(object $walker, array $children, array $args, string $output): void#
$childrenarray<int|string, list<object>>