RegionPickerTrait
Parent region picker (single field, self-reference); follows {@see PagePickerTrait}. The manager carries the trait itself (`#[Inject]`), so the presenter must not take it in the constructor (property collision).
The edited region and its descendants cannot be its parent: they are excluded from the suggester
(lft/rgt) and from the modal (pickerExclude + subtree bounds). The label is translations.name
in the current language.
Table of Contents
Properties
Methods
- buildRegionMunicipalityValidator() : callable(int): bool
- Selection validator for `ParameterFormContext::$regionValidator`: active municipality only (tree leaf).
- regionParentPicker() : PickerConfig
- regionPicker() : PickerConfig
- Region picker as a plain FK reference (single field, no self-reference), e.g. the region of an event or advert. Suggester plus a modal with the `show` grid `:Admin:System:Region`.
- regionSuggestPicker() : PickerConfig
- Picker for a `REGION_PICKER` parameter (municipality/postcode suggester).
- regionPickerName() : string
- Region name in the current language (falls back to the first non-empty one).
- resolveRegionLabel() : string|null
- resolveRegionLocalityLabel() : string|null
- Label of the stored value = region name (a legacy advert assigned to a country shows the country name).
- resolveRegionPickerLanguageId() : int
-
suggestRegionLocalities()
: array<int, array{id: int, label: string, data: array
}> - suggestRegions() : array<int, array{id: int, label: string}>
- Suggester: `LIKE` over the region name; optionally without the excluded node and its whole subtree (parent self-reference).
Properties
$regionManager
public
RegionManager
$regionManager
Attributes
- #[Inject]
Methods
buildRegionMunicipalityValidator()
Selection validator for `ParameterFormContext::$regionValidator`: active municipality only (tree leaf).
protected
buildRegionMunicipalityValidator() : callable(int): bool
Return values
callable(int): boolregionParentPicker()
protected
regionParentPicker([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 region (self-reference)
- $excludeLft : int|null = null
-
lft of the edited region (subtree exclusion)
- $excludeRgt : int|null = null
-
rgt of the edited region (subtree exclusion)
Return values
PickerConfigregionPicker()
Region picker as a plain FK reference (single field, no self-reference), e.g. the region of an event or advert. Suggester plus a modal with the `show` grid `:Admin:System:Region`.
protected
regionPicker([string $formName = 'editForm' ][, string $targetField = 'regionId' ]) : PickerConfig
Parameters
- $formName : string = 'editForm'
-
name of the form holding the hidden field (
editForm) - $targetField : string = 'regionId'
-
name of the hidden control (
regionId)
Return values
PickerConfigregionSuggestPicker()
Picker for a `REGION_PICKER` parameter (municipality/postcode suggester).
protected
regionSuggestPicker(string $formName, string $targetField[, array<string, string> $fieldMap = [] ][, bool $leafOnly = true ]) : PickerConfig
The suggester uses the same Api suggest as the front end (ordered by weight, path, postcode),
not its own LIKE query. The modal with the regions show grid stays (tree browsing);
selecting a non-municipality is rejected by the server-side form validation.
Parameters
- $formName : string
- $targetField : string
- $fieldMap : array<string, string> = []
-
data key (
city/zip/country) -> control name; preview only, the Api splits the real values on save - $leafOnly : bool = true
-
municipalities only (advert form)
Return values
PickerConfigregionPickerName()
Region name in the current language (falls back to the first non-empty one).
private
regionPickerName(Region $region) : string
Parameters
- $region : Region
Return values
stringresolveRegionLabel()
private
resolveRegionLabel(int $id) : string|null
Parameters
- $id : int
Return values
string|nullresolveRegionLocalityLabel()
Label of the stored value = region name (a legacy advert assigned to a country shows the country name).
private
resolveRegionLocalityLabel(int $id) : string|null
Parameters
- $id : int
Return values
string|nullresolveRegionPickerLanguageId()
private
resolveRegionPickerLanguageId() : int
Return values
intsuggestRegionLocalities()
private
suggestRegionLocalities(string $query, bool $leafOnly) : array<int, array{id: int, label: string, data: array}>
Parameters
- $query : string
- $leafOnly : bool
Return values
array<int, array{id: int, label: string, data: arraysuggestRegions()
Suggester: `LIKE` over the region name; optionally without the excluded node and its whole subtree (parent self-reference).
private
suggestRegions(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