CoolCMS API

TreeMoveExpectation
in package

FinalYes

Expected tree state from which the client (drag and drop in the admin grid) derived a move.

The server verifies it under the tree lock right before writing (TreeTrait::moveSubtree()):

  • the moved node is still under oldParentId,
  • prevId/nextId are currently adjacent siblings under the target parent (the moved node is excluded from the adjacency). If anything does not match, ResultCode::TREE_STALE is returned and nothing is written.

Semantics (same as afterId of the grid signal):

  • oldParentId null means the node was at the root level,
  • prevId -1 means to the start of the parent, 0 means to the end without verifying neighbours (a drop on a collapsed node whose children the client does not know), >0 means right after this sibling,
  • nextId 0 means nothing follows the node (end of the parent), >0 means right before this sibling.

The combination prevId = 0 + nextId > 0 makes no sense (the end and "before something" at once) and the repository rejects it as INVALID_ARGUMENT.

Not a DI service: built by hand and passed over ApiBridge as an array (toArray() / fromArray()), like TreeConfig.

Table of Contents

Constants

NEXT_NONE  : mixed = 0
PREV_FIRST  : mixed = -1
PREV_LAST_UNCHECKED  : mixed = 0

Properties

$nextId  : int
$oldParentId  : int|null
$prevId  : int

Methods

__construct()  : mixed
fromArray()  : self|null
Rebuilds the expectation from a bridge payload. When both `prevId` and `nextId` are missing, no expectation was sent and the result is `null` (a move without a contract, backward compatible). `oldParentId` 0 / null / non-numeric means the root.
getAfterId()  : int
`afterId` for {@see \App\Core\Traits\Api\Models\Managers\TreeTrait::moveSubtreeTo()}; `prevId` determines the position, `nextId` only verifies.
isTargetEmpty()  : bool
Tells whether the contract expects the target parent to have no children (besides the moved node).
toArray()  : array{oldParentId: int|null, prevId: int, nextId: int}

Constants

Properties

Methods

__construct()

public __construct(int|null $oldParentId, int $prevId, int $nextId) : mixed
Parameters
$oldParentId : int|null
$prevId : int
$nextId : int

fromArray()

Rebuilds the expectation from a bridge payload. When both `prevId` and `nextId` are missing, no expectation was sent and the result is `null` (a move without a contract, backward compatible). `oldParentId` 0 / null / non-numeric means the root.

public static fromArray(mixed $data) : self|null
Parameters
$data : mixed
Return values
self|null

getAfterId()

`afterId` for {@see \App\Core\Traits\Api\Models\Managers\TreeTrait::moveSubtreeTo()}; `prevId` determines the position, `nextId` only verifies.

public getAfterId() : int
Return values
int

isTargetEmpty()

Tells whether the contract expects the target parent to have no children (besides the moved node).

public isTargetEmpty() : bool
Return values
bool

toArray()

public toArray() : array{oldParentId: int|null, prevId: int, nextId: int}
Return values
array{oldParentId: int|null, prevId: int, nextId: int}
On this page

Search results