RegionRepository
extends ApiRepository
in package
Front repository that reads through the Api bridge and uses the query cache when the service has it enabled (`cache.config.enabledServices`).
This is the deliberate opposite of ApiRepository: the front end only displays data, so a 5 minute old number is at most cosmetic, whereas the admin reads it into a form that is written back to the DB.
->useCache(false) on the query object overrides the policy for one query; it travels
to the payload as ApiBridge::PARAM_USE_CACHE.
IMPORTANT: null is passed on as null (no opinion), not as true. If this layer
substituted true, it would override QueryCacheContext, and
reads through a front manager inside an admin request (AssetManager, ThemeManager,
UserManager) would still be served from the cache. The true default therefore lives
in the bridge.
Table of Contents
Properties
- $apiEndpoint : string
- Api presenter path (e.g. `api/system/page`); set by each concrete repository.
- $bridge : ApiBridge
Methods
- __construct() : mixed
- find() : array<string|int, mixed>
- findAll() : array<string|int, mixed>
- findBy() : array<string|int, mixed>
- findLocality() : array<string, mixed>|null
- Region node for validating a municipality choice / label: internal action `internalActionLocality()` (privilege `:Api:System:Region:locality`).
- geocode() : array{latitude: mixed, longitude: mixed, cached: bool}|null
- Point of a free text of the "within X km" filter: internal action `internalActionGeocode()` (privilege `:Api:System:Region:geocode`); the Api does cache, then Google, then a cache write.
-
suggest()
: array{items: list
>, limited: bool} - Municipality/postcode suggester: internal action `Api\System\Presenters\RegionPresenter::internalActionSuggest()` (no `action*()`, privilege `:Api:System:Region:suggest`). The parameters are already normalized; the Api normalizes them again.
- failSoftRead() : array<string|int, mixed>
- Normalizes a bridge response to plain data; a failed envelope or a non-array gives `[]`.
- getApiCallSource() : string
- Branch marker for writes ({@see ApiBridge::PARAM_SOURCE}), read by the shared repository `SaveTrait`.
Properties
$apiEndpoint
Api presenter path (e.g. `api/system/page`); set by each concrete repository.
protected
string
$apiEndpoint
= 'api/system/region'
$bridge read-only
protected
ApiBridge
$bridge
Methods
__construct()
public
__construct(ApiBridge $bridge) : mixed
Parameters
- $bridge : ApiBridge
find()
public
find(int $id[, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : array<string|int, mixed>
Parameters
- $id : int
- $includes : string|array<string|int, mixed> = []
- $useCache : bool|null = null
Return values
array<string|int, mixed>findAll()
public
findAll([array<string|int, mixed>|null $filters = [] ][, array<string|int, mixed>|null $orderBys = null ][, int|null $offset = null ][, int|null $limit = null ][, array<string|int, mixed>|null $columns = null ][, bool $computeTotalCount = false ][, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : array<string|int, mixed>
Parameters
- $filters : array<string|int, mixed>|null = []
- $orderBys : array<string|int, mixed>|null = null
- $offset : int|null = null
- $limit : int|null = null
- $columns : array<string|int, mixed>|null = null
- $computeTotalCount : bool = false
- $includes : string|array<string|int, mixed> = []
- $useCache : bool|null = null
Return values
array<string|int, mixed>findBy()
public
findBy([array<string|int, mixed>|null $filters = [] ][, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : array<string|int, mixed>
Parameters
- $filters : array<string|int, mixed>|null = []
- $includes : string|array<string|int, mixed> = []
- $useCache : bool|null = null
Return values
array<string|int, mixed>findLocality()
Region node for validating a municipality choice / label: internal action `internalActionLocality()` (privilege `:Api:System:Region:locality`).
public
findLocality(int $id, int $languageId) : array<string, mixed>|null
Parameters
- $id : int
- $languageId : int
Return values
array<string, mixed>|null —null = the node does not exist or the Api did not answer
geocode()
Point of a free text of the "within X km" filter: internal action `internalActionGeocode()` (privilege `:Api:System:Region:geocode`); the Api does cache, then Google, then a cache write.
public
geocode(string $q, int $languageId, int $preferRegionId) : array{latitude: mixed, longitude: mixed, cached: bool}|null
Parameters
- $q : string
- $languageId : int
- $preferRegionId : int
Return values
array{latitude: mixed, longitude: mixed, cached: bool}|null —null = not found / the Api did not answer
suggest()
Municipality/postcode suggester: internal action `Api\System\Presenters\RegionPresenter::internalActionSuggest()` (no `action*()`, privilege `:Api:System:Region:suggest`). The parameters are already normalized; the Api normalizes them again.
public
suggest(string $q, int $languageId, int $preferRegionId, int $minLevel, bool $leafOnly, int $limit) : array{items: list>, limited: bool}
Parameters
- $q : string
- $languageId : int
- $preferRegionId : int
- $minLevel : int
- $leafOnly : bool
- $limit : int
Return values
array{items: listfailSoftRead()
Normalizes a bridge response to plain data; a failed envelope or a non-array gives `[]`.
protected
failSoftRead(mixed $response, string $endpoint) : array<string|int, mixed>
NOTE: it does not log on purpose. ApiBridge::call(), which sees both the
endpoint and the caller, has already written the API_FAILSOFT source=bridge line; a second
copy would turn one failure into three lines in auth.log.
Parameters
- $response : mixed
- $endpoint : string
-
only for call readability; the log takes the endpoint from the bridge
Return values
array<string|int, mixed>getApiCallSource()
Branch marker for writes ({@see ApiBridge::PARAM_SOURCE}), read by the shared repository `SaveTrait`.
protected
getApiCallSource() : string