CoolCMS API

ArticleMapper extends ApiMapper
in package
uses RegisterEventTrait

FinalYes

Front mapper that hydrates Api repository data into entities.

Tags
extends

Table of Contents

Properties

$hydrator  : EntityHydrator
$repository  : ArticleRepository

Methods

__construct()  : mixed
find()  : T|null
findAll()  : T>, 1: int}
findBy()  : T|null
registerEvent()  : Result
search()  : Article>, 1: int, 2: bool, 3: array>}|null
Searches through the Api endpoint `search`. Hydration follows the payload order ({@see EntityHydrator::hydrateAll()} iterates `items` as they came), so ES relevance reaches the front end naturally; the endpoint already reordered the items on the Api side (`SearchTrait::orderItemsByIds`).
getEntityClass()  : T>
initalizeEntity()  : Article|null
highlights()  : array<int, array<string, string>>
Snippets from the endpoint: `article id => field => HTML`. Values are already escaped and may contain only `<em>` (converted by {@see \App\Core\Integrations\Elasticsearch\Search\EsHighlighter} on the Api side); only the shape is checked here, so that nothing the endpoint did not give reaches the template (where they are printed with `|noescape`).

Properties

Methods

find()

public find(int $pageId[, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : T|null
Parameters
$pageId : int
$includes : string|array<string|int, mixed> = []
$useCache : bool|null = null
Return values
T|null

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 ]) : T>, 1: int}
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
T>, 1: int}

findBy()

public findBy([array<string|int, mixed>|null $filters = [] ][, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : T|null
Parameters
$filters : array<string|int, mixed>|null = []
$includes : string|array<string|int, mixed> = []
$useCache : bool|null = null
Return values
T|null

registerEvent()

public registerEvent(array<string|int, int> $ids, string $property) : Result
Parameters
$ids : array<string|int, int>
$property : string
Return values
Result

Searches through the Api endpoint `search`. Hydration follows the payload order ({@see EntityHydrator::hydrateAll()} iterates `items` as they came), so ES relevance reaches the front end naturally; the endpoint already reordered the items on the Api side (`SearchTrait::orderItemsByIds`).

public search(string $search, string|null $languageAlias[, array<int, object|array<string, mixed>> $filters = [] ][, array<string, mixed>|null $orderBys = null ][, int|null $offset = null ][, int|null $limit = null ][, string|array<int, string> $includes = [] ]) : Article>, 1: int, 2: bool, 3: array>}|null
Parameters
$search : string
$languageAlias : string|null
$filters : array<int, object|array<string, mixed>> = []
$orderBys : array<string, mixed>|null = null
$offset : int|null = null
$limit : int|null = null
$includes : string|array<int, string> = []
Return values
Article>, 1: int, 2: bool, 3: array>}|null —

[entities, totalCount, fromEs, highlights]; null means the response is not a list (deny envelope or bridge outage); the caller must fall back to the plain DB path instead of rendering an empty list

getEntityClass()

protected getEntityClass() : T>
Return values
T>

initalizeEntity()

protected initalizeEntity(array<string, mixed> $row) : Article|null
Parameters
$row : array<string, mixed>
Return values
Article|null

highlights()

Snippets from the endpoint: `article id => field => HTML`. Values are already escaped and may contain only `<em>` (converted by {@see \App\Core\Integrations\Elasticsearch\Search\EsHighlighter} on the Api side); only the shape is checked here, so that nothing the endpoint did not give reaches the template (where they are printed with `|noescape`).

private static highlights(array<string, mixed> $payload) : array<int, array<string, string>>
Parameters
$payload : array<string, mixed>
Return values
array<int, array<string, string>>
On this page

Search results