CoolCMS API

TreeRowsBuilder
in package

FinalYes

Builds the visible grid tree from nodes loaded by parent (`parentId IN (root + expanded)`, ordered by `lft`).

Knows neither entities nor the database: takes only id / parentId / lft / rgt and returns the row order (depth-first), template metadata and the nested structure for sorting. This keeps it testable without a database.

Rules:

  • only nodes reachable from the view root (rootId = focused node, null = real roots) through expanded nodes are shown; other loaded nodes are silently ignored,
  • "has children" is rgt - lft > 1 (no query); actually loaded children count too, so a broken nested set cannot hide rows the database holds under the parent,
  • up/down arrows come from bounds: first child when lft == parent.lft + 1, last when rgt == parent.rgt - 1; for real roots MIN(lft) / MAX(rgt) of the roots (all roots are always loaded, so these are the bounds of the whole scope),
  • children of one parent above childrenLimit: the first N are rendered, the rest becomes the more count (the "N more" row),
  • pinnedId (target of the "In tree" action): a node beyond the limit is rendered extra, after the "N more" row (the rest shrinks by one); otherwise focusing on the parent would not show it. DOM adjacency no longer holds, so the server rejects a move next to it.

Table of Contents

Methods

build()  : array{order: list, meta: array, moreAfter: array>, nested: list, rootMore: int}

Methods

build()

public static build(array<int, array{id: int, parentId: int|null, lft: int, rgt: int|null}> $nodes, int|null $rootId, array{lft: int, rgt: int}|null $rootBounds, array<int, true>|null $expanded, int $childrenLimit[, int|null $pinnedId = null ]) : array{order: list, meta: array, moreAfter: array>, nested: list, rootMore: int}
Parameters
$nodes : array<int, array{id: int, parentId: int|null, lft: int, rgt: int|null}>

nodes ordered by lft

$rootId : int|null

focused node (its children form the first level); null = real roots

$rootBounds : array{lft: int, rgt: int}|null

bounds of the focused node (arrows of its children)

$expanded : array<int, true>|null

expanded nodes; null = everything expanded

$childrenLimit : int
$pinnedId : int|null = null

node that must be visible even beyond the children limit (highlighted row)

Return values
array{order: list, meta: array, moreAfter: array>, nested: list, rootMore: int}
On this page

Search results