TreeTrait
Api endpoints of tree operations.
move-upcallsinternalActionMoveUp(manager->moveUp);move-downcallsinternalActionMoveDown(manager->moveDown);delete-nodecallsinternalActionDeleteNode(manager->deleteNode, deletes the subtree);reorder-childrencallsinternalActionReorderChildren(manager->reorderChildren; internal bridge only).
ApiBridge calls internalAction<Action>(...$params) internally with named args, so the parameter
names (id, treeConfig) must match the bridge payload. TreeConfig travels as an array and
is rebuilt here, as is the optional move expectation (expectation, TreeMoveExpectation)
of move-subtree-to.
Table of Contents
Methods
- actionDeleteNode() : void
- actionInsertTreeNode() : void
- actionMoveDown() : void
- actionMoveSubtree() : void
- actionMoveSubtreeTo() : void
- actionMoveUp() : void
- internalActionDeleteNode() : array<string, mixed>
- internalActionInsertTreeNode() : array<string, mixed>
- internalActionMoveDown() : array<string, mixed>
- internalActionMoveSubtree() : array<string, mixed>
- internalActionMoveSubtreeTo() : array<string, mixed>
- `$expectation` is {@see TreeMoveExpectation::toArray()} (`oldParentId`, `prevId`, `nextId`); null moves without verifying the state (forms, older clients). The parameter name must match the bridge payload key (named args).
- internalActionMoveUp() : array<string, mixed>
- internalActionReorderChildren() : array<string, mixed>
- Reorders the direct children of a parent (`reorder-children`, internal bridge only); see {@see \App\Core\Traits\Api\Models\Managers\TreeTrait::reorderChildren()}.
- requireTreeManager() : TreeManagerInterface
- Returns the tree manager; a presenter without one has no tree actions.
- resolveTreeRequestAfterId() : int|null
- Resolves the sibling to insert after: missing, `null`, `''` or `0` means first position.
- resolveTreeRequestConfig() : array<string|int, mixed>|null
- resolveTreeRequestExpectation() : array<string|int, mixed>|false|null
- resolveTreeRequestId() : int|null
- Resolves the node id of an external tree mutation. Only a canonical positive id passes; otherwise HTTP 400 is sent and `null` returned. `(int) ['999']` is `1`, so without the check `id[]=...` would move or delete node 1 (with its subtree).
- resolveTreeRequestParentId() : int|false|null
- Resolves the new parent: missing, `null` or `''` means root (`null`), `0` is kept as the zero sentinel, otherwise a canonical positive id. `false` means rejected (HTTP 400 already sent); without it `newParentId[]=5` would fall back to `null`, i.e. a move to the root.
- resultToArray() : array<string, mixed>
Methods
actionDeleteNode()
public
actionDeleteNode() : void
actionInsertTreeNode()
public
actionInsertTreeNode() : void
actionMoveDown()
public
actionMoveDown() : void
actionMoveSubtree()
public
actionMoveSubtree() : void
actionMoveSubtreeTo()
public
actionMoveSubtreeTo() : void
actionMoveUp()
public
actionMoveUp() : void
internalActionDeleteNode()
public
internalActionDeleteNode(int $id[, array<string, mixed> $treeConfig = [] ]) : array<string, mixed>
Parameters
- $id : int
- $treeConfig : array<string, mixed> = []
Return values
array<string, mixed>internalActionInsertTreeNode()
public
internalActionInsertTreeNode(int $id[, array<string, mixed> $treeConfig = [] ]) : array<string, mixed>
Parameters
- $id : int
- $treeConfig : array<string, mixed> = []
Return values
array<string, mixed>internalActionMoveDown()
public
internalActionMoveDown(int $id[, array<string, mixed> $treeConfig = [] ]) : array<string, mixed>
Parameters
- $id : int
- $treeConfig : array<string, mixed> = []
Return values
array<string, mixed>internalActionMoveSubtree()
public
internalActionMoveSubtree(int $id, int|null $newParentId[, array<string, mixed> $treeConfig = [] ]) : array<string, mixed>
Parameters
- $id : int
- $newParentId : int|null
- $treeConfig : array<string, mixed> = []
Return values
array<string, mixed>internalActionMoveSubtreeTo()
`$expectation` is {@see TreeMoveExpectation::toArray()} (`oldParentId`, `prevId`, `nextId`); null moves without verifying the state (forms, older clients). The parameter name must match the bridge payload key (named args).
public
internalActionMoveSubtreeTo(int $id, int|null $newParentId, int $afterId[, array<string, mixed> $treeConfig = [] ][, array<string, mixed>|null $expectation = null ]) : array<string, mixed>
Parameters
- $id : int
- $newParentId : int|null
- $afterId : int
- $treeConfig : array<string, mixed> = []
- $expectation : array<string, mixed>|null = null
Return values
array<string, mixed>internalActionMoveUp()
public
internalActionMoveUp(int $id[, array<string, mixed> $treeConfig = [] ]) : array<string, mixed>
Parameters
- $id : int
- $treeConfig : array<string, mixed> = []
Return values
array<string, mixed>internalActionReorderChildren()
Reorders the direct children of a parent (`reorder-children`, internal bridge only); see {@see \App\Core\Traits\Api\Models\Managers\TreeTrait::reorderChildren()}.
protected
internalActionReorderChildren(int|null $parentId, array<int, int|string> $childIds[, array<string, mixed> $treeConfig = [] ]) : array<string, mixed>
Deliberately not public and without action*(): it is a variant of moving subtrees (it only
changes child order, like drag and drop), so it shares the RBAC key moveSubtreeTo; an own key
would need a privilege seed for every tree presenter with no added value (an allowed pattern
of a bridge-only method, checked by ApiPermissionCoverageTest). Parameter names are the
bridge payload keys.
Parameters
- $parentId : int|null
- $childIds : array<int, int|string>
-
child ids in the new order
- $treeConfig : array<string, mixed> = []
Return values
array<string, mixed>requireTreeManager()
Returns the tree manager; a presenter without one has no tree actions.
private
requireTreeManager() : TreeManagerInterface
Return values
TreeManagerInterfaceresolveTreeRequestAfterId()
Resolves the sibling to insert after: missing, `null`, `''` or `0` means first position.
private
resolveTreeRequestAfterId(array<string, mixed> $params) : int|null
null means rejected (HTTP 400 already sent).
Parameters
- $params : array<string, mixed>
Return values
int|nullresolveTreeRequestConfig()
private
resolveTreeRequestConfig(array<string, mixed> $params) : array<string|int, mixed>|null
Parameters
- $params : array<string, mixed>
Return values
array<string|int, mixed>|null —null means rejected (HTTP 400 already sent)
resolveTreeRequestExpectation()
private
resolveTreeRequestExpectation(array<string, mixed> $params) : array<string|int, mixed>|false|null
Parameters
- $params : array<string, mixed>
Return values
array<string|int, mixed>|false|null —null means no expectation, false means rejected
resolveTreeRequestId()
Resolves the node id of an external tree mutation. Only a canonical positive id passes; otherwise HTTP 400 is sent and `null` returned. `(int) ['999']` is `1`, so without the check `id[]=...` would move or delete node 1 (with its subtree).
private
resolveTreeRequestId(array<string, mixed> $params) : int|null
Parameters
- $params : array<string, mixed>
Return values
int|nullresolveTreeRequestParentId()
Resolves the new parent: missing, `null` or `''` means root (`null`), `0` is kept as the zero sentinel, otherwise a canonical positive id. `false` means rejected (HTTP 400 already sent); without it `newParentId[]=5` would fall back to `null`, i.e. a move to the root.
private
resolveTreeRequestParentId(array<string, mixed> $params) : int|false|null
Parameters
- $params : array<string, mixed>
Return values
int|false|nullresultToArray()
private
resultToArray(Result $result) : array<string, mixed>
Parameters
- $result : Result