CategoryPickerTrait
Company catalog category picker with two uses.
- categorySinglePicker(): a single field (category of a payment or watchdog),
- categoryParentPicker(): the parent category (self-reference: excludes the edited category and its whole subtree).
The label is the name (translations.name) in the current language. Suggestions plus a modal
with the show grid :Admin:Comcat:Category.
Table of Contents
Properties
Methods
- categoryParentPicker() : PickerConfig
- Builds the parent category picker (single field, self-reference).
- categorySinglePicker() : PickerConfig
- Single field: a category FK in a foreign form (payment, watchdog).
- categoryName() : string
- Returns the category name in the current language (falls back to the first non-empty one).
- resolveCategoryLabel() : string|null
- suggestCategories() : array<int, array{id: int, label: string}>
- Suggests categories by a name match, optionally without the excluded node and its subtree.
Properties
$categoryManager
public
CategoryManager
$categoryManager
Attributes
- #[Inject]
Methods
categoryParentPicker()
Builds the parent category picker (single field, self-reference).
protected
categoryParentPicker([string $formName = 'editForm' ][, string $targetField = 'parentId' ][, int|null $excludeId = null ][, int|null $excludeLft = null ][, int|null $excludeRgt = null ]) : PickerConfig
The edited category and its descendants must not become the parent, so they are excluded
from the suggestions (lft/rgt) and from the modal.
Parameters
- $formName : string = 'editForm'
- $targetField : string = 'parentId'
- $excludeId : int|null = null
-
id of the edited category (self-reference)
- $excludeLft : int|null = null
-
lftof the edited category (subtree exclusion) - $excludeRgt : int|null = null
-
rgtof the edited category (subtree exclusion)
Return values
PickerConfigcategorySinglePicker()
Single field: a category FK in a foreign form (payment, watchdog).
protected
categorySinglePicker([string $formName = 'editForm' ][, string $targetField = 'categoryId' ]) : PickerConfig
Parameters
- $formName : string = 'editForm'
- $targetField : string = 'categoryId'
Return values
PickerConfigcategoryName()
Returns the category name in the current language (falls back to the first non-empty one).
private
categoryName(Category $category) : string
Parameters
- $category : Category
Return values
stringresolveCategoryLabel()
private
resolveCategoryLabel(int $id) : string|null
Parameters
- $id : int
Return values
string|nullsuggestCategories()
Suggests categories by a name match, optionally without the excluded node and its subtree.
private
suggestCategories(string $query[, int|null $excludeId = null ][, int|null $excludeLft = null ][, int|null $excludeRgt = null ]) : array<int, array{id: int, label: string}>
Parameters
- $query : string
- $excludeId : int|null = null
- $excludeLft : int|null = null
- $excludeRgt : int|null = null