TreeTrait
Bridge calls of tree operations to the Api endpoints `move-up`, `move-down`, `delete-node`, `move-subtree(-to)` and `reorder-children`.
It is generic, like SaveTrait, and shared by both bridge stacks (Admin and Front).
Table of Contents
Methods
- deleteTreeNode() : Result
- insertTreeNode() : Result
- moveSubtree() : Result
- moveSubtreeTo() : Result
- moveTreeNode() : Result
- reorderChildren() : Result
- Propagates `data.changed` from the Api (number of children that changed place) into the result.
- callTreeEndpoint() : Result
Methods
deleteTreeNode()
public
deleteTreeNode(int $id, TreeConfig $config) : Result
Parameters
- $id : int
- $config : TreeConfig
Return values
ResultinsertTreeNode()
public
insertTreeNode(int $id, TreeConfig $config) : Result
Parameters
- $id : int
- $config : TreeConfig
Return values
ResultmoveSubtree()
public
moveSubtree(int $id, int|null $newParentId, TreeConfig $config) : Result
Parameters
- $id : int
- $newParentId : int|null
-
null moves to the root level
- $config : TreeConfig
Return values
ResultmoveSubtreeTo()
public
moveSubtreeTo(int $id, int|null $newParentId, int $afterId, TreeConfig $config[, TreeMoveExpectation|null $expectation = null ]) : Result
Parameters
- $id : int
- $newParentId : int|null
-
null is the root level
- $afterId : int
-
-1 first child, 0 last child, >0 after that sibling
- $config : TreeConfig
- $expectation : TreeMoveExpectation|null = null
-
always sent, even when null; the internal bridge calls
internalActionMoveSubtreeTo(...$params)with named arguments
Return values
ResultmoveTreeNode()
public
moveTreeNode(int $id, int $direction, TreeConfig $config) : Result
Parameters
- $id : int
- $direction : int
- $config : TreeConfig
Return values
ResultreorderChildren()
Propagates `data.changed` from the Api (number of children that changed place) into the result.
public
reorderChildren(int|null $parentId, array<int, int> $orderedIds, TreeConfig $config) : Result
Parameters
- $parentId : int|null
-
null is the root level
- $orderedIds : array<int, int>
-
child ids in the new order
- $config : TreeConfig
Return values
ResultcallTreeEndpoint()
private
callTreeEndpoint(string $action, int $id, TreeConfig $config, string $failureMessage) : Result
Parameters
- $action : string
- $id : int
- $config : TreeConfig
- $failureMessage : string