CoolCMS API

PublicAdvertReadFilterTrait uses trait:short

Api reads of adverts and categories (Bazaar, Comcat) by an external non-privileged caller return only what the website shows: an advert that is published (`active`, the generated column with approval, payment, bans and deletion, and not expired) or owned by the caller, a category that is active.

Decision of the site owner: the guest keeps the right to read, the presenter filters. The internal bridge (the front and the admin) is not filtered: the front applies its own visibility (owner preview, edit by key, payment of an unpaid advert) and the admin is privileged. Built on InactiveRecordsReadFilterTrait (filters the _references after the query cache); the host returns false from publicReadIsAdvert() for a category presenter.

Table of Contents

Methods

filterReadPayload()  : array<string, mixed>
inactiveFilterDependentClasses()  : array<string, string>
Dependent classes (typically translations) mapped to the name of their parent pointer.
inactiveFilterEntityClass()  : string
Class of the main entity in `_references` (the presenter's Api entity).
inactiveFilterHiddenFields()  : array<int, string>
isLiveRecord()  : bool
publicReadIsAdvert()  : bool
Whether the entity is an advert (owner and expiration rules) or a category (only `active`).
filterInactiveRecords()  : array<string, mixed>
pointerId()  : int|string|null
Returns the id from a `{id: N}` or `{id: {id: N}}` pointer (reference in `_references` / `items`), or null for any other shape.

Methods

filterReadPayload()

protected filterReadPayload(array<string, mixed> $payload, string $action) : array<string, mixed>
Parameters
$payload : array<string, mixed>
$action : string
Return values
array<string, mixed>

inactiveFilterDependentClasses()

Dependent classes (typically translations) mapped to the name of their parent pointer.

protected inactiveFilterDependentClasses() : array<string, string>

Their rows are removed together with a hidden parent, otherwise the draft text would stay in _references.

Return values
array<string, string> —

class => field holding the {id: {id: N}} pointer

inactiveFilterEntityClass()

Class of the main entity in `_references` (the presenter's Api entity).

protected abstract inactiveFilterEntityClass() : string
Return values
string

inactiveFilterHiddenFields()

protected inactiveFilterHiddenFields() : array<int, string>
Return values
array<int, string>

isLiveRecord()

protected isLiveRecord(array<string|int, mixed> $row) : bool
Parameters
$row : array<string|int, mixed>
Return values
bool

publicReadIsAdvert()

Whether the entity is an advert (owner and expiration rules) or a category (only `active`).

protected abstract publicReadIsAdvert() : bool
Return values
bool

filterInactiveRecords()

private filterInactiveRecords(array<string, mixed> $payload, string $action) : array<string, mixed>
Parameters
$payload : array<string, mixed>
$action : string
Return values
array<string, mixed>

pointerId()

Returns the id from a `{id: N}` or `{id: {id: N}}` pointer (reference in `_references` / `items`), or null for any other shape.

private static pointerId(mixed $pointer) : int|string|null
Parameters
$pointer : mixed
Return values
int|string|null
On this page

Search results