CoolCMS API

RegionSuggestQuery
in package

FinalYes

Query of the municipality/postcode suggester.

Input normalization lives here and only here: Front calls it before the bridge, Admin and Api presenters call it again (bridge input is not trusted), so all paths trim the same way. Values are plain data (scalars) sent over the bridge one by one.

  • name = diacritics-free form of the text (single spaces), for name_ascii like;
  • postcode = digits only, when the input contains only digits after removing spaces (at least 3); the postcode branch is searched then and name is empty.

Table of Contents

Constants

DEFAULT_LIMIT  : int = 10
LIKE_ESCAPE  : string = '!'
Escape character for `like ... escape '!'`, independent of `NO_BACKSLASH_ESCAPES`.
MAX_LENGTH  : int = 100
MAX_LIMIT  : int = 20
MIN_NAME_LENGTH  : int = 2
MIN_POSTCODE_LENGTH  : int = 3

Properties

$languageId  : int
$leafOnly  : bool
$limit  : int
$minLevel  : int
$name  : string
$postcode  : string|null
$preferRegionId  : int|null

Methods

escapeLike()  : string
Escapes user input for `like ... escape '!'`. `%` and `_` are ordinary characters for the user and must not become wildcards ("%" would return everything).
fromInput()  : self
isEmpty()  : bool
Returns whether there is nothing to search for (short input, punctuation only); no query is sent to the database.
normalizeInputLength()  : string
Trims and cuts free text to the max length (no diacritics removal, it goes to the external geocoder).
normalizeText()  : string
Trims, cuts to the max length, removes diacritics and unifies spaces.
__construct()  : mixed

Constants

LIKE_ESCAPE

Escape character for `like ... escape '!'`, independent of `NO_BACKSLASH_ESCAPES`.

public string LIKE_ESCAPE = '!'

Properties

Methods

escapeLike()

Escapes user input for `like ... escape '!'`. `%` and `_` are ordinary characters for the user and must not become wildcards ("%" would return everything).

public static escapeLike(string $value) : string
Parameters
$value : string
Return values
string

fromInput()

public static fromInput(string $raw, int $languageId[, int|null $preferRegionId = null ][, int $minLevel = 2 ][, bool $leafOnly = false ][, int $limit = self::DEFAULT_LIMIT ]) : self
Parameters
$raw : string

user input (any length, diacritics, spaces)

$languageId : int
$preferRegionId : int|null = null

country (level 1) whose items take precedence, from the website localization

$minLevel : int = 2

lowest tree level (1 = country included, 2 = from region)

$leafOnly : bool = false

only tree leaves of type municipality (advert form)

$limit : int = self::DEFAULT_LIMIT
Return values
self

isEmpty()

Returns whether there is nothing to search for (short input, punctuation only); no query is sent to the database.

public isEmpty() : bool
Return values
bool

normalizeInputLength()

Trims and cuts free text to the max length (no diacritics removal, it goes to the external geocoder).

public static normalizeInputLength(string $raw) : string
Parameters
$raw : string
Return values
string

normalizeText()

Trims, cuts to the max length, removes diacritics and unifies spaces.

public static normalizeText(string $raw) : string
Parameters
$raw : string
Return values
string

__construct()

private __construct(string $name, string|null $postcode, int $languageId, int|null $preferRegionId, int $minLevel, bool $leafOnly, int $limit) : mixed
Parameters
$name : string
$postcode : string|null
$languageId : int
$preferRegionId : int|null
$minLevel : int
$leafOnly : bool
$limit : int
On this page

Search results