CustomAssetPickerTrait
Custom code picker: a multiplier row in the "Custom code" tab of the page form selects a {@see CustomAsset} from the library. Like {@see \App\UI\Admin\Blog\Presenters\Traits\Pickers\GalleryPickerTrait} (multiplier picker without ordering): the code itself carries the relation (M:N to `Page`), the tab only selects which id belongs to the set.
Requires $this->customAssetManager
(CustomAssetManager) in the host;
PagePresenter already has it injected by the constructor for the tab defaults.
Table of Contents
Methods
- addCustomAssetPickerControls() : void
- Adds the picker controls (hidden id plus text label) to a multiplier row.
- customAssetPicker() : PickerConfig
- customAssetPickerLabel() : string
- resolveCustomAssetLabel() : string|null
- suggestCustomAssets() : array<int, array{id: int, label: string}>
- Suggestions: `LIKE` on `name`, label "name (type, placement)".
- trCustomAssetPickerOption() : string
- Translates an absolute key; the trait is used in presenters with different domains.
Methods
addCustomAssetPickerControls()
Adds the picker controls (hidden id plus text label) to a multiplier row.
protected
addCustomAssetPickerControls(Container $parent[, string $targetField = 'assetId' ][, string $displayField = 'asset' ]) : void
Parameters
- $parent : Container
- $targetField : string = 'assetId'
- $displayField : string = 'asset'
customAssetPicker()
protected
customAssetPicker([string $formName = 'editForm' ][, string|null $container = 'customAssets' ][, string $targetField = 'assetId' ][, string $displayField = 'asset' ]) : PickerConfig
Parameters
- $formName : string = 'editForm'
- $container : string|null = 'customAssets'
- $targetField : string = 'assetId'
- $displayField : string = 'asset'
Return values
PickerConfigcustomAssetPickerLabel()
private
customAssetPickerLabel(CustomAsset $asset) : string
Parameters
- $asset : CustomAsset
Return values
stringresolveCustomAssetLabel()
private
resolveCustomAssetLabel(int $id) : string|null
Parameters
- $id : int
Return values
string|nullsuggestCustomAssets()
Suggestions: `LIKE` on `name`, label "name (type, placement)".
private
suggestCustomAssets(string $query) : array<int, array{id: int, label: string}>
Parameters
- $query : string
Return values
array<int, array{id: int, label: string}>trCustomAssetPickerOption()
Translates an absolute key; the trait is used in presenters with different domains.
private
trCustomAssetPickerOption(string $key) : string
Parameters
- $key : string