CoolCMS API

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

moveSubtree()

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
Result

moveSubtreeTo()

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
Result

reorderChildren()

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
Result

callTreeEndpoint()

private callTreeEndpoint(string $action, int $id, TreeConfig $config, string $failureMessage) : Result
Parameters
$action : string
$id : int
$config : TreeConfig
$failureMessage : string
Return values
Result
On this page

Search results