MenuItemPickerTrait
Parent menu item picker, like {@see PagePickerTrait}, but the parent must come from the same menu: the suggestions and the modal are scoped by the current `$this->menuId`.
Unlike PagePickerTrait, the trait injects no manager of its own. It uses
$this->menuItemManager and $this->menuId of the host presenter
(MenuPresenter), because the picker is bound to
one concrete menu tree. An own #[Inject] property would collide with the constructor's
private readonly MenuItemManager.
Usage:
protected function pickers(): array
{
return ['parentId' => $this->menuItemPicker('editForm', 'parentId', $excludeId, $lft, $rgt)];
}
Table of Contents
Methods
- menuItemPicker() : PickerConfig
- menuItemLabel() : string
- menuItemPickerLangId() : int
- resolveMenuItemLabel() : string|null
- Label to prefill on edit (from the hidden value).
- suggestMenuItems() : array<int, array{id: int, label: string}>
- Suggestions: `OR LIKE` over the item name and title, only within the current menu; optionally without the excluded node and its whole subtree (an item must not be its own parent or the parent of its descendant).
Methods
menuItemPicker()
protected
menuItemPicker(string $formName, string $targetField[, int|null $excludeId = null ][, int|null $excludeSubtreeLft = null ][, int|null $excludeSubtreeRgt = null ]) : PickerConfig
Parameters
- $formName : string
-
form name with the hidden field (
editForm) - $targetField : string
-
name of the hidden control (
parentId) - $excludeId : int|null = null
-
id that must not be selected (self-reference); excluded from the suggestions and the modal (passed to the
showgrid viapickerExclude) - $excludeSubtreeLft : int|null = null
-
lft of the edited node, to exclude the whole subtree
- $excludeSubtreeRgt : int|null = null
-
rgt of the edited node, to exclude the whole subtree
Return values
PickerConfigmenuItemLabel()
private
menuItemLabel(MenuItem $item, int $langId) : string
Parameters
- $item : MenuItem
- $langId : int
Return values
stringmenuItemPickerLangId()
private
menuItemPickerLangId() : int
Return values
intresolveMenuItemLabel()
Label to prefill on edit (from the hidden value).
private
resolveMenuItemLabel(int $id) : string|null
Parameters
- $id : int
Return values
string|nullsuggestMenuItems()
Suggestions: `OR LIKE` over the item name and title, only within the current menu; optionally without the excluded node and its whole subtree (an item must not be its own parent or the parent of its descendant).
private
suggestMenuItems(string $query[, int|null $excludeId = null ][, int|null $excludeSubtreeLft = null ][, int|null $excludeSubtreeRgt = null ]) : array<int, array{id: int, label: string}>
Parameters
- $query : string
- $excludeId : int|null = null
- $excludeSubtreeLft : int|null = null
- $excludeSubtreeRgt : int|null = null