CategoryPickerTrait
Advert category picker, used two ways: - {@see categorySinglePicker()}: a single field (category of a payment/watchdog), - {@see 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. Suggester plus a modal with the
show grid :Admin:Bazaar:Category. See CategoryPickerTrait.
Table of Contents
Properties
Methods
- categoryParentPicker() : PickerConfig
- Parent category picker (single field, self-reference). The edited category and its descendants cannot be the parent, so they are excluded from the suggester (`lft`/`rgt`) and from the modal.
- categorySinglePicker() : PickerConfig
- Single field: a category (FK) for a foreign form (payment, watchdog).
- categoryName() : string
- 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}>
- Suggester: `like` search over the category name; optionally without the excluded node and its subtree.
Properties
$categoryManager
public
CategoryManager
$categoryManager
Attributes
- #[Inject]
Methods
categoryParentPicker()
Parent category picker (single field, self-reference). The edited category and its descendants cannot be the parent, so they are excluded from the suggester (`lft`/`rgt`) and from the modal.
protected
categoryParentPicker([string $formName = 'editForm' ][, string $targetField = 'parentId' ][, int|null $excludeId = null ][, int|null $excludeLft = null ][, int|null $excludeRgt = null ]) : PickerConfig
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) for a foreign form (payment, watchdog).
protected
categorySinglePicker([string $formName = 'editForm' ][, string $targetField = 'categoryId' ]) : PickerConfig
Parameters
- $formName : string = 'editForm'
- $targetField : string = 'categoryId'
Return values
PickerConfigcategoryName()
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()
Suggester: `like` search over the category name; 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