CoolCMS API

TimeSlotRepository extends ApiRepository
in package
uses BridgeFailureTrait

FinalYes

Admin repository that reads through the Api bridge and bypasses the query cache by default.

find(), findBy() and findAll() send ApiBridge::PARAM_USE_CACHE = false. $useCache is ?bool: null leaves the decision to this layer (false); an explicit true (->useCache(true) on the query) is respected and is the only way to request the cache.

IMPORTANT: an admin form is a read followed by a write, so a stale cached value would be written back to the DB (silent data regression). Invalidation cannot cover it: the view counters (views, viewsList, viewsDetail) are deliberately excluded from it (SaveTrait::$nonInvalidatingColumns), because bumping on every detail view would drop the cache of all lists.

NOTE: this default is not the only safeguard. The main switch is QueryCacheContext, turned off for the whole request by BasePresenter::startup(), because an admin request also runs front managers (AssetManager, ThemeManager, UserManager) through the front repository. This default covers admin reads outside an admin request (CLI harness, admin cron).

Table of Contents

Properties

$apiEndpoint  : string
Api presenter path (e.g. `api/system/page`); set by each concrete repository.
$bridge  : ApiBridge

Methods

__construct()  : mixed
availability()  : array<int|string, mixed>
Returns the day overview of a month through the narrow Api action `availability`.
availabilityForCalendar()  : array<int|string, mixed>
Returns the day overview of a month for one calendar (admin calendar switcher).
dayDetail()  : array<int|string, mixed>
Returns the day detail including reservation identities (admin-only Api action `dayDetail`).
delete()  : Result
deleteAll()  : Result
find()  : array<string|int, mixed>
findAll()  : array<string|int, mixed>
findBy()  : array<string|int, mixed>
openWindow()  : Result
Creates a time slot at a time outside the offer, like {@see shorten()}.
save()  : Result
shorten()  : Result
Shortens a time slot with an active reservation (time slot edit modal).
split()  : Result
Splits a time slot with an active reservation, like {@see shorten()}.
updateColumns()  : Result
bridgeException()  : Result
Turns a caught bridge exception into `API_ERROR` without the exception text; the detail goes to the `admin.bridge` log channel.
bridgeMessage()  : string|null
Returns the message of a flat bridge response: null for a failure with a technical code (detail goes to the log), otherwise unchanged.
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`.
actionResult()  : Result
Builds a `Result` by hand from the flat Api response.

Properties

$apiEndpoint

Api presenter path (e.g. `api/system/page`); set by each concrete repository.

protected string $apiEndpoint = 'api/company/time-slot'

Methods

availability()

Returns the day overview of a month through the narrow Api action `availability`.

public availability(int $companyId, string $month) : array<int|string, mixed>

The action is guest-readable and bridge-only (no action*()); the admin uses it here because it also returns days without their own TimeSlot row (source = 'default'), which a raw entity grid cannot show. The resolution logic lives only on the Api side (TimeSlotManager::availability()); do not duplicate it here.

Parameters
$companyId : int
$month : string
Return values
array<int|string, mixed> —

empty array on failure or rejection (fail-soft)

availabilityForCalendar()

Returns the day overview of a month for one calendar (admin calendar switcher).

public availabilityForCalendar(int $calendarId, string $month) : array<int|string, mixed>

Mirrors availability() with a different body parameter, which the Api action tells apart, see TimeSlotPresenter::internalActionAvailability().

Parameters
$calendarId : int
$month : string
Return values
array<int|string, mixed> —

empty array on failure or rejection (fail-soft)

dayDetail()

Returns the day detail including reservation identities (admin-only Api action `dayDetail`).

public dayDetail(int $calendarId, string $date) : array<int|string, mixed>

Mirrors availabilityForCalendar() with a different endpoint and payload. The day window and reservation identity logic lives only on the Api side (TimeSlotManager::dayDetailForCalendar()); do not duplicate it here.

Parameters
$calendarId : int
$date : string
Return values
array<int|string, mixed> —

empty array on failure or rejection (fail-soft)

delete()

public delete(int|array<string|int, mixed> $id) : Result
Parameters
$id : int|array<string|int, mixed>
Return values
Result

deleteAll()

public deleteAll([array<string|int, mixed> $filters = [] ]) : Result
Parameters
$filters : array<string|int, mixed> = []
Return values
Result

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>

openWindow()

Creates a time slot at a time outside the offer, like {@see shorten()}.

public openWindow(int $calendarId, string $date, string $timeFrom, string $timeTo) : Result
Parameters
$calendarId : int
$date : string
$timeFrom : string
$timeTo : string
Return values
Result

save()

public save(array<string, mixed> $data[, array<string, mixed> $meta = [] ][, array<int, string> $skipFields = [] ]) : Result
Parameters
$data : array<string, mixed>

extracted entity payload

$meta : array<string, mixed> = []
$skipFields : array<int, string> = []
Return values
Result

shorten()

Shortens a time slot with an active reservation (time slot edit modal).

public shorten(int $timeSlotId, string $timeFrom, string $timeTo, bool $notifyClient) : Result

The Api shorten is a narrow admin-only action without action*(), bridge-only like confirm/cancel in ReservationRepository. It is not the generic save()/updateColumns() because only this action may legally change the time of an occupied row (TimeSlotManager::shorten()).

NOTE: the calendar and the day are not sent; the Api reads them from the stored row under the day lock.

Parameters
$timeSlotId : int
$timeFrom : string
$timeTo : string
$notifyClient : bool
Return values
Result

split()

Splits a time slot with an active reservation, like {@see shorten()}.

public split(int $timeSlotId, string $cutTime, bool $notifyClient) : Result
Parameters
$timeSlotId : int
$cutTime : string
$notifyClient : bool
Return values
Result

updateColumns()

public updateColumns(array<string|int, mixed> $ids, array<string, mixed> $values) : Result
Parameters
$ids : array<string|int, mixed>

ids or composite-id arrays

$values : array<string, mixed>

property name => new value

Return values
Result

bridgeException()

Turns a caught bridge exception into `API_ERROR` without the exception text; the detail goes to the `admin.bridge` log channel.

protected bridgeException(Throwable $e, string $endpoint) : Result
Parameters
$e : Throwable
$endpoint : string
Return values
Result

bridgeMessage()

Returns the message of a flat bridge response: null for a failure with a technical code (detail goes to the log), otherwise unchanged.

protected bridgeMessage(array<string, mixed> $response, ResultCode $code, string $endpoint) : string|null
Parameters
$response : array<string, mixed>
$code : ResultCode
$endpoint : string
Return values
string|null

failSoftRead()

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
Return values
string

actionResult()

Builds a `Result` by hand from the flat Api response.

private actionResult(string $action, array<string, mixed> $payload) : Result

internalActionShorten()/internalActionSplit() return a flat envelope (TimeSlotPresenter::result() on the Api side), not the standard five-key Result envelope, see ReservationRepository::resultFromActionResponse(). Scalar extras (the range after shortening, the flag for a created freed part) are passed through as data.

Parameters
$action : string
$payload : array<string, mixed>
Return values
Result
On this page

Search results