ReservationRepository
extends ApiRepository
in package
Front repository that reads through the Api bridge and uses the query cache when the service has it enabled (`cache.config.enabledServices`).
This is the deliberate opposite of ApiRepository: the front end only displays data, so a 5 minute old number is at most cosmetic, whereas the admin reads it into a form that is written back to the DB.
->useCache(false) on the query object overrides the policy for one query; it travels
to the payload as ApiBridge::PARAM_USE_CACHE.
IMPORTANT: null is passed on as null (no opinion), not as true. If this layer
substituted true, it would override QueryCacheContext, and
reads through a front manager inside an admin request (AssetManager, ThemeManager,
UserManager) would still be served from the cache. The true default therefore lives
in the bridge.
Table of Contents
Properties
- $apiEndpoint : string
- Api presenter path (e.g. `api/system/page`); set by each concrete repository.
- $bridge : ApiBridge
Methods
- __construct() : mixed
- book() : array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null, timeFrom?: string|null, timeTo?: string|null, retryAfter?: int, errorCode?: string|null}
- Books a time slot for a customer.
- cancelByToken() : array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null, timeFrom?: string|null, timeTo?: string|null, retryAfter?: int, errorCode?: string|null}
- Cancels a reservation as a guest through the one-time token from the e-mail.
- cancelMy() : array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null, timeFrom?: string|null, timeTo?: string|null, retryAfter?: int, errorCode?: string|null}
- Cancels the logged-in customer's own reservation.
- find() : array<string|int, mixed>
- findAll() : array<string|int, mixed>
- findBy() : array<string|int, mixed>
- findMyReservations() : array<string, mixed>
- Returns the reservations of the logged-in customer.
- 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`.
- normalizeResultEnvelope() : array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null}
- Checks only the response shape, so the caller never receives `mixed` after a transport failure.
Properties
$apiEndpoint
Api presenter path (e.g. `api/system/page`); set by each concrete repository.
protected
string
$apiEndpoint
= 'api/company/reservation'
$bridge read-only
protected
ApiBridge
$bridge
Methods
__construct()
public
__construct(ApiBridge $bridge) : mixed
Parameters
- $bridge : ApiBridge
book()
Books a time slot for a customer.
public
book(string $date, string $timeFrom, string $timeTo, string $name, string $email, string|null $phone, string|null $note, bool $gdprConsent[, int|null $calendarId = null ][, string|null $subject = null ]) : array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null, timeFrom?: string|null, timeTo?: string|null, retryAfter?: int, errorCode?: string|null}
Api narrow action book
(ReservationPresenter::internalActionBook()).
companyId is not sent (the server uses the presented company); the Api takes userId and the IP from the JWT and the request itself.
$calendarId is the public calendar the visitor picked in the switcher; null makes the server use the company's default calendar. $subject is an optional subject. Both are last in the signature with defaults, so existing positional calls stay valid.
IMPORTANT: the response is not a Result envelope (no exception / data keys; flat reservationId / state / timeFrom / timeTo instead), so FailSoftReadTrait is deliberately not used. success: false is the meaning of the call here (slot taken, limit reached), not a defect of the response; the component builds a translated message from it.
Parameters
- $date : string
- $timeFrom : string
- $timeTo : string
- $name : string
- $email : string
- $phone : string|null
- $note : string|null
- $gdprConsent : bool
- $calendarId : int|null = null
- $subject : string|null = null
Return values
array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null, timeFrom?: string|null, timeTo?: string|null, retryAfter?: int, errorCode?: string|null}cancelByToken()
Cancels a reservation as a guest through the one-time token from the e-mail.
public
cancelByToken(string $token) : array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null, timeFrom?: string|null, timeTo?: string|null, retryAfter?: int, errorCode?: string|null}
Api narrow action cancelByToken
(ReservationPresenter::internalActionCancelByToken()).
Same contract as self::book(): the envelope is propagated, not filtered.
Parameters
- $token : string
Return values
array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null, timeFrom?: string|null, timeTo?: string|null, retryAfter?: int, errorCode?: string|null}cancelMy()
Cancels the logged-in customer's own reservation.
public
cancelMy(int $id) : array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null, timeFrom?: string|null, timeTo?: string|null, retryAfter?: int, errorCode?: string|null}
Api narrow action myCancel. The identity comes from the JWT (the front end bridge carries it itself). Someone else's, missing or already canceled reservation returns the same readable failure, same contract as cancelByToken.
Parameters
- $id : int
Return values
array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null, timeFrom?: string|null, timeTo?: string|null, retryAfter?: int, errorCode?: string|null}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>findMyReservations()
Returns the reservations of the logged-in customer.
public
findMyReservations([int|null $offset = null ][, int|null $limit = null ][, bool $computeTotalCount = true ]) : array<string, mixed>
Api narrow action myList: a bridge only, without action*(), like
CompanyRepository::findPresented().
The server takes the scope from the JWT; the front end sends no userId.
IMPORTANT: the response has an extra slots key besides the standard {items, totalCount, _references} shape; both are hydrated by ReservationMapper::findMyReservations().
Parameters
- $offset : int|null = null
- $limit : int|null = null
- $computeTotalCount : bool = true
Return values
array<string, mixed>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
stringnormalizeResultEnvelope()
Checks only the response shape, so the caller never receives `mixed` after a transport failure.
private
static normalizeResultEnvelope(mixed $response) : array{success: bool, code: int|null, message: string|null, reservationId: int|null, state: string|null}
Unlike failSoftRead() it does not discard the envelope: success: false passes through unchanged.
Parameters
- $response : mixed