RegionLocality
in package
Data of one region node needed to validate a selection and to split an advert address into city / postcode / country on save.
Plain data (scalars + postcode list); it crosses the bridge as an array.
Table of Contents
Constants
- TYPE_MUNICIPALITY : string = 'municipality'
Properties
- $active : bool
- $country : string
- $countryCode : string
- $latitude : float|null
- $leaf : bool
- $level : int
- $longitude : float|null
- $name : string
- $postcode : string|null
- $postcodes : array<string|int, mixed>
- $regionId : int
- $type : string
Methods
- __construct() : mixed
- formatPostcode() : string
- "60200" -> "602 00" (display); any other shape is returned unchanged.
- fromArray() : self|null
- getCoordinates() : GeoCoordinates|null
- Returns the node center for geocoding: the node's own coordinates; a region, district or country without them gets the average of its municipalities from the repository.
- isSelectableMunicipality() : bool
- Returns whether the node may be saved on an advert: only an active leaf of type municipality.
- normalizePostcode() : string|null
- "602 00" / "60200" -> "60200"; anything other than 5 digits -> null.
- resolvePostcode() : string|null
- Returns the postcode stored on the advert, in this order: 1. the submitted postcode when it belongs to the selected municipality (picked via the postcode branch of the suggester), 2. the submitted postcode in a valid format when the field is visible and editable (Comcat: a municipality has several postcodes and the user knows theirs; "postcode belongs to the municipality" is not enforced), 3. otherwise the main postcode of the municipality (`cms_system_regions.postcode`).
-
toArray()
: array{regionId: int, name: string, type: string, level: int, active: bool, leaf: bool, countryCode: string, country: string, postcode: ?string, postcodes: list
, latitude: ?float, longitude: ?float}
Constants
TYPE_MUNICIPALITY
public
string
TYPE_MUNICIPALITY
= 'municipality'
Properties
$active read-only
public
bool
$active
$country read-only
public
string
$country
$countryCode read-only
public
string
$countryCode
$latitude read-only
public
float|null
$latitude
= null
$leaf read-only
public
bool
$leaf
$level read-only
public
int
$level
$longitude read-only
public
float|null
$longitude
= null
$name read-only
public
string
$name
$postcode read-only
public
string|null
$postcode
$postcodes read-only
public
array<string|int, mixed>
$postcodes
= []
$regionId read-only
public
int
$regionId
$type read-only
public
string
$type
Methods
__construct()
public
__construct(int $regionId, string $name, string $type, int $level, bool $active, bool $leaf, string $countryCode, string $country, string|null $postcode[, array<int, string> $postcodes = [] ][, float|null $latitude = null ][, float|null $longitude = null ]) : mixed
Parameters
- $regionId : int
- $name : string
- $type : string
- $level : int
- $active : bool
- $leaf : bool
- $countryCode : string
- $country : string
- $postcode : string|null
- $postcodes : array<int, string> = []
-
all postcodes of the municipality (without spaces) from
cms_system_region_postcodes - $latitude : float|null = null
- $longitude : float|null = null
formatPostcode()
"60200" -> "602 00" (display); any other shape is returned unchanged.
public
static formatPostcode(string $value) : string
Parameters
- $value : string
Return values
stringfromArray()
public
static fromArray(array<string, mixed> $row) : self|null
Parameters
- $row : array<string, mixed>
Return values
self|nullgetCoordinates()
Returns the node center for geocoding: the node's own coordinates; a region, district or country without them gets the average of its municipalities from the repository.
public
getCoordinates() : GeoCoordinates|null
null means no point.
Return values
GeoCoordinates|nullisSelectableMunicipality()
Returns whether the node may be saved on an advert: only an active leaf of type municipality.
public
isSelectableMunicipality() : bool
Return values
boolnormalizePostcode()
"602 00" / "60200" -> "60200"; anything other than 5 digits -> null.
public
static normalizePostcode(string $value) : string|null
Parameters
- $value : string
Return values
string|nullresolvePostcode()
Returns the postcode stored on the advert, in this order: 1. the submitted postcode when it belongs to the selected municipality (picked via the postcode branch of the suggester), 2. the submitted postcode in a valid format when the field is visible and editable (Comcat: a municipality has several postcodes and the user knows theirs; "postcode belongs to the municipality" is not enforced), 3. otherwise the main postcode of the municipality (`cms_system_regions.postcode`).
public
resolvePostcode(string|null $submitted, bool $editable) : string|null
Parameters
- $submitted : string|null
- $editable : bool
Return values
string|nulltoArray()
public
toArray() : array{regionId: int, name: string, type: string, level: int, active: bool, leaf: bool, countryCode: string, country: string, postcode: ?string, postcodes: list, latitude: ?float, longitude: ?float}