TreeMoveExpectation
in package
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/nextIdare currently adjacent siblings under the target parent (the moved node is excluded from the adjacency). If anything does not match,ResultCode::TREE_STALEis returned and nothing is written.
Semantics (same as afterId of the grid signal):
oldParentIdnull 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,nextId0 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
NEXT_NONE
public
mixed
NEXT_NONE
= 0
PREV_FIRST
public
mixed
PREV_FIRST
= -1
PREV_LAST_UNCHECKED
public
mixed
PREV_LAST_UNCHECKED
= 0
Properties
$nextId read-only
public
int
$nextId
$oldParentId read-only
public
int|null
$oldParentId
$prevId read-only
public
int
$prevId
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|nullgetAfterId()
`afterId` for {@see \App\Core\Traits\Api\Models\Managers\TreeTrait::moveSubtreeTo()}; `prevId` determines the position, `nextId` only verifies.
public
getAfterId() : int
Return values
intisTargetEmpty()
Tells whether the contract expects the target parent to have no children (besides the moved node).
public
isTargetEmpty() : bool
Return values
booltoArray()
public
toArray() : array{oldParentId: int|null, prevId: int, nextId: int}