InitializationTrait
Loads grid data from the manager: translates the state (persistent parameters) into Core filters and ordering and runs the fetch.
Two modes:
- flat list: filters, ordering and paging in SQL (Api layer),
- tree list (
setTreeStructureand no user ordering or filters): loads by parents (the root or focused node plus expanded nodes) without paging. TreeRowsBuilder computes levels, arrows, "has children" and the children cap; TreeStateTrait holds the expanded and focus state.
Table of Contents
Properties
- $initialized : bool
- $items : array<int, object>
- $itemsById : array<int, object>
- $totalCount : int
- $treeMeta : array<int, array{level: int, parentId: int, hasChildren: bool, expanded: bool, up: bool, down: bool}>
- Metadata of the visible tree nodes ({@see TreeRowsBuilder}).
- $treeMoreAfter : array<int, array<int, array{parentId: int, count: int, level: int}>>
- $treeNested : array<int, array{id: int, children: array, more: int}>
- $treeRootMore : int
- How many children of the view root did not fit under the cap.
Methods
- buildParentFilter() : Filter
- Builds `parentId IS NULL` (roots) or `= focused node`, plus children of expanded nodes.
- buildStateFilters() : array<string|int, Filter>
- Converts search field values into Core filters via the column filter definitions.
- decorateItems() : void
- Calls {@see DataGrid::setRowDecorator()} on the current page when it is set.
- initializeData() : void
- isTreeView() : bool
- Tells whether the tree list applies: only in the chosen tree view ({@see TreeStateTrait::isTreeViewChosen()}) and until the user searches or sorts by a column, which breaks the hierarchy and switches the grid to the flat list. The default view is the flat paged list.
- loadFlatData() : void
- loadTreeData() : void
- Loads the tree list by parents: one query `parentId IN (root or focused node + expanded)` ordered by `lft`, without paging.
- resolveOrderBys() : array<string, bool>
- Returns the ordering for `findAll()`; user ordering takes precedence over the default.
- resolveTreeParentId() : int|null
Properties
$initialized
private
bool
$initialized
= false
$items
private
array<int, object>
$items
= []
records of the current page
$itemsById
private
array<int, object>
$itemsById
= []
id => entity of the loaded tree
$totalCount
private
int
$totalCount
= 0
$treeMeta
Metadata of the visible tree nodes ({@see TreeRowsBuilder}).
private
array<int, array{level: int, parentId: int, hasChildren: bool, expanded: bool, up: bool, down: bool}>
$treeMeta
= []
$treeMoreAfter
private
array<int, array<int, array{parentId: int, count: int, level: int}>>
$treeMoreAfter
= []
row id => "N more" rows after its subtree
$treeNested
private
array<int, array{id: int, children: array, more: int}>
$treeNested
= []
nesting for the sort view
$treeRootMore
How many children of the view root did not fit under the cap.
private
int
$treeRootMore
= 0
Methods
buildParentFilter()
Builds `parentId IS NULL` (roots) or `= focused node`, plus children of expanded nodes.
private
buildParentFilter(object|null $rootNode, array<int, int> $expandedIds) : Filter
Parameters
- $rootNode : object|null
- $expandedIds : array<int, int>
Return values
FilterbuildStateFilters()
Converts search field values into Core filters via the column filter definitions.
private
buildStateFilters() : array<string|int, Filter>
Return values
array<string|int, Filter>decorateItems()
Calls {@see DataGrid::setRowDecorator()} on the current page when it is set.
private
decorateItems() : void
initializeData()
private
initializeData() : void
isTreeView()
Tells whether the tree list applies: only in the chosen tree view ({@see TreeStateTrait::isTreeViewChosen()}) and until the user searches or sorts by a column, which breaks the hierarchy and switches the grid to the flat list. The default view is the flat paged list.
private
isTreeView() : bool
Return values
boolloadFlatData()
private
loadFlatData(array<string|int, Filter> $coreFilters) : void
Parameters
- $coreFilters : array<string|int, Filter>
loadTreeData()
Loads the tree list by parents: one query `parentId IN (root or focused node + expanded)` ordered by `lft`, without paging.
private
loadTreeData(array<string|int, Filter> $coreFilters) : void
The default state (the user has not collapsed anything) and a non-collapsible tree (menu) mean "everything expanded". For a tree up to DataGrid::TREE_FULL_LIMIT nodes that equals a query without the parent filter (limited to the subtree under focus), so the whole tree is loaded at once. TreeRowsBuilder handles visibility, arrows and the children cap over the same data.
Parameters
- $coreFilters : array<string|int, Filter>
resolveOrderBys()
Returns the ordering for `findAll()`; user ordering takes precedence over the default.
private
resolveOrderBys() : array<string, bool>
Return values
array<string, bool> —property path => true (asc) / false (desc)
resolveTreeParentId()
private
resolveTreeParentId(object $entity) : int|null
Parameters
- $entity : object