TreePositionConfig
in package
Configuration of one {@see TreePosition} instance: where to take the children of the target parent from and which form the choice belongs to. A pure value object (not a DI service, `config/common.neon` excludes it from search, like `PickerConfig`).
Children are drawn through a callback, so the component knows neither the manager nor the label of a concrete entity; a regular tree builds it through forManager().
Table of Contents
Properties
- $allowKeep : bool
- $childrenCallback : Closure
- $formName : string
- $nodeId : int|null
- $parentField : string
Methods
- __construct() : mixed
- forManager() : self
- Builds the config for a regular tree: children of the parent from the manager (`parentProperty = id` / `IS NULL`, ordered by `lft`), label from the property path in the current language (`translations.name`).
- getChildren() : array<int, array{id: int, label: string}>
- Returns the children of the parent without the moved node.
- getFormName() : string
- getNodeId() : int|null
- getParentField() : string
- isKeepAllowed() : bool
Properties
$allowKeep read-only
private
bool
$allowKeep
= false
$childrenCallback read-only
private
Closure
$childrenCallback
$formName read-only
private
string
$formName
$nodeId read-only
private
int|null
$nodeId
= null
$parentField read-only
private
string
$parentField
= 'parentId'
Methods
__construct()
public
__construct(callable(Array, Array): array<int, array{id: int, label: string}> $childrenCallback, string $formName[, string $parentField = 'parentId' ][, int|null $nodeId = null ][, bool $allowKeep = false ]) : mixed
Parameters
- $childrenCallback : callable(Array, Array): array<int, array{id: int, label: string}>
-
(parent id / null for the root level, language id) -> children ordered by
lft - $formName : string
-
form that holds both the position and the parent field (searched upward from the component)
- $parentField : string = 'parentId'
-
name of the control with the target parent id (the picker's hidden field)
- $nodeId : int|null = null
-
moved or edited node, left out of the siblings; null means a new record
- $allowKeep : bool = false
-
offer "Keep current position" (edit form, default choice)
forManager()
Builds the config for a regular tree: children of the parent from the manager (`parentProperty = id` / `IS NULL`, ordered by `lft`), label from the property path in the current language (`translations.name`).
public
static forManager(Manager<BaseEntity, ServiceInterface<string|int, BaseEntity>> $manager, string $labelProperty, string $formName, int|null $nodeId[, bool $allowKeep = true ][, array<int, string> $includes = ['translations'] ][, array<int, Filter> $scopeFilters = [] ][, string $parentField = 'parentId' ][, string $parentProperty = 'parentId' ][, string $orderProperty = 'lft' ]) : self
Parameters
- $manager : Manager<BaseEntity, ServiceInterface<string|int, BaseEntity>>
- $labelProperty : string
- $formName : string
- $nodeId : int|null
- $allowKeep : bool = true
- $includes : array<int, string> = ['translations']
- $scopeFilters : array<int, Filter> = []
-
tree scope (items of one menu)
- $parentField : string = 'parentId'
- $parentProperty : string = 'parentId'
- $orderProperty : string = 'lft'
Return values
selfgetChildren()
Returns the children of the parent without the moved node.
public
getChildren(int|null $parentId, int|null $langId) : array<int, array{id: int, label: string}>
Parameters
- $parentId : int|null
- $langId : int|null
Return values
array<int, array{id: int, label: string}>getFormName()
public
getFormName() : string
Return values
stringgetNodeId()
public
getNodeId() : int|null
Return values
int|nullgetParentField()
public
getParentField() : string
Return values
stringisKeepAllowed()
public
isKeepAllowed() : bool