CoolCMS API

AdvertListTrait uses trait:short, trait:short, trait:short, trait:short

Table of Contents

Constants

LIST_INCLUDES  : mixed = ['parameterRels.parameter.translations', 'asset...
Includes of the list; identical for the DB path and the search endpoint.

Properties

$categoryId  : string|null
$consentGateFactory  : ConsentGateFactory

Methods

actionList()  : void
createComponentConsentGate()  : ConsentGate
paginationInit()  : Paginator|null
prepareFilters()  : array<int, Filter>
renderList()  : void
requirePagination()  : Paginator
Works like `paginationInit()`, but the paginator is required; a missing component is a wiring error.
prepareCanonicalUrl()  : void
prepareMetaDataForDetail()  : void
prepareMetaDataForList()  : void
prepareOgDataForDetail()  : void
prepareOgDataForList()  : void
prepareOrderBy()  : array<string, bool>
preparePerPage()  : int
preparePriceFilter()  : void
Adds the upper price bound from the URL (`?priceTo=...`) sent by `SearchBox`.
prepareSearchFilters()  : array<int, Filter>
Builds the filters for the search endpoint: everything except fulltext (the Api side does it, ES or `MATCH_AGAINST`). That is visibility + category/region + parameter filters from `$_GET['p']`, which are DB phase 1.
prepareView()  : void
searchViaApi()  : Advert>, 1: int, 2: bool, 3: array>}|null
Searches adverts through the Api endpoint `api/bazaar/advert/search` instead of building the filter in the presenter. Three states:

Constants

LIST_INCLUDES

Includes of the list; identical for the DB path and the search endpoint.

private mixed LIST_INCLUDES = ['parameterRels.parameter.translations', 'assetRels.asset.translations', 'categoryRels.category.translations', 'user']

Properties

$categoryId

public string|null $categoryId = null
Attributes
#[Persistent]

Methods

actionList()

public actionList(int|null $page, string|int|null $category, string|int|null $loc, int|null $order) : void
Parameters
$page : int|null
$category : string|int|null
$loc : string|int|null
$order : int|null

prepareFilters()

public prepareFilters([bool $useParameterFilters = true ]) : array<int, Filter>
Parameters
$useParameterFilters : bool = true
Return values
array<int, Filter>

renderList()

public renderList(int $page, string|int|null $category, string|int $loc, int $order[, int $count = 20 ]) : void
Parameters
$page : int
$category : string|int|null
$loc : string|int
$order : int
$count : int = 20

requirePagination()

Works like `paginationInit()`, but the paginator is required; a missing component is a wiring error.

public requirePagination(int $perPage) : Paginator
Parameters
$perPage : int
Return values
Paginator

prepareCanonicalUrl()

private prepareCanonicalUrl([array<string, mixed> $resetParams = [] ]) : void
Parameters
$resetParams : array<string, mixed> = []

prepareMetaDataForDetail()

private prepareMetaDataForDetail(Advert|null $entity, string $titlePrName, string $textPrName) : void
Parameters
$entity : Advert|null
$titlePrName : string
$textPrName : string

prepareMetaDataForList()

private prepareMetaDataForList([Category|null $category = null ]) : void
Parameters
$category : Category|null = null

prepareOgDataForDetail()

private prepareOgDataForDetail(Advert|null $entity, string $titlePrName, string $textPrName) : void
Parameters
$entity : Advert|null
$titlePrName : string
$textPrName : string

prepareOgDataForList()

private prepareOgDataForList([Category|null $category = null ]) : void
Parameters
$category : Category|null = null

prepareOrderBy()

private prepareOrderBy() : array<string, bool>
Return values
array<string, bool>

preparePerPage()

private preparePerPage(int $count[, int $defaultCount = 20 ]) : int
Parameters
$count : int
$defaultCount : int = 20
Return values
int

preparePriceFilter()

Adds the upper price bound from the URL (`?priceTo=...`) sent by `SearchBox`.

private preparePriceFilter(array<int, Filter> &$filters) : void

It filters the denormalized indexed column advert.price (decimal), not the parameter price: a parameter value is text and can be neither compared nor indexed. The column exists for sorting but fits a range just as well.

IMPORTANT: adverts without a price (price IS NULL, typically "by agreement") are not shown when a bound is chosen. This is intended: the user set a ceiling and an offer without a price cannot meet it.

Without the parameter in the URL nothing is added.

Parameters
$filters : array<int, Filter>

prepareSearchFilters()

Builds the filters for the search endpoint: everything except fulltext (the Api side does it, ES or `MATCH_AGAINST`). That is visibility + category/region + parameter filters from `$_GET['p']`, which are DB phase 1.

private prepareSearchFilters() : array<int, Filter>
Return values
array<int, Filter>

searchViaApi()

Searches adverts through the Api endpoint `api/bazaar/advert/search` instead of building the filter in the presenter. Three states:

private searchViaApi(string $search, bool $orderChosen, Paginator|null $paginator) : Advert>, 1: int, 2: bool, 3: array>}|null

(a) search without a manual sort choice: orderBys = null, ES sorts and pages by score (fromEs: true); visibility and parameter filters stay in the DB, (b) search with a manual choice (/o-N in the URL): orderBys from prepareOrderBy(), the DB sorts, pages and counts over the ES id set and relevance is not used, (c) without a search this path is not taken at all and nothing changes.

NOTE: in state (a) the precedence of topped adverts does not apply. prepareOrderBy() normally puts topedUntil > NOW() first, but on the relevance path ES sorts by score and the DB does not take part in the order. Without a search, and with a manual sort choice, topping works unchanged.

All filters are sent, including the $_GET['p'] parameter filters: they are DB phase 1 just like visibility, and the ES ids are only candidates.

null = use the DB path: the endpoint returned no list (deny or bridge outage), or ES is not running and without a manual choice the DB branch of the endpoint would return unsorted rows.

Parameters
$search : string
$orderChosen : bool
$paginator : Paginator|null
Return values
Advert>, 1: int, 2: bool, 3: array>}|null —

[entities, totalCount, fromEs, highlights]

On this page

Search results