ReservationRepository
extends ApiRepository
in package
uses
BridgeFailureTrait
Confirms and cancels reservations through the narrow Api actions `confirm`/`cancel`.
The actions are bridge-only (no action*()), like
MessageThreadRepository::replyToThread().
They are not the generic save()/updateColumns() because a state change must pass the
Api guard (only pending to confirmed, pending/confirmed to cancelled) and send
the e-mail, which updateColumns() does not trigger.
Table of Contents
Properties
- $apiEndpoint : string
- Api presenter path (e.g. `api/system/page`); set by each concrete repository.
- $bridge : ApiBridge
Methods
- __construct() : mixed
- bookByAdmin() : Result
- Creates a reservation on behalf of the client from the time slot edit modal.
- cancel() : Result
- confirm() : Result
- delete() : Result
- deleteAll() : Result
- find() : array<string|int, mixed>
- findAll() : array<string|int, mixed>
- findBy() : array<string|int, mixed>
- mergeSlots() : Result
- Merges adjacent time slots.
- save() : Result
- updateByAdmin() : Result
- Edits a reservation from the modal (name, e-mail, phone, note, state).
- 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`.
- resultFromActionResponse() : 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/reservation'
$bridge read-only
protected
ApiBridge
$bridge
Methods
__construct()
public
__construct(ApiBridge $bridge) : mixed
Parameters
- $bridge : ApiBridge
bookByAdmin()
Creates a reservation on behalf of the client from the time slot edit modal.
public
bookByAdmin(int $calendarId, string $date, string $timeFrom, string $timeTo, string $name, string $email, string|null $phone, string|null $note, string $state, bool $notifyClient) : Result
The Api bookByAdmin is a narrow admin-only action without action*(), like
confirm/cancel above. It is not the public book: it has no data-protection consent checkbox and no
lead time, and the admin chooses the state. companyId is not sent; the Api derives it
from the calendar, which owns the row.
Parameters
- $calendarId : int
- $date : string
- $timeFrom : string
- $timeTo : string
- $name : string
- $email : string
- $phone : string|null
- $note : string|null
- $state : string
- $notifyClient : bool
Return values
Resultcancel()
public
cancel(int $id) : Result
Parameters
- $id : int
Return values
Resultconfirm()
public
confirm(int $id) : Result
Parameters
- $id : int
Return values
Resultdelete()
public
delete(int|array<string|int, mixed> $id) : Result
Parameters
- $id : int|array<string|int, mixed>
Return values
ResultdeleteAll()
public
deleteAll([array<string|int, mixed> $filters = [] ]) : Result
Parameters
- $filters : array<string|int, mixed> = []
Return values
Resultfind()
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>mergeSlots()
Merges adjacent time slots.
public
mergeSlots(int $calendarId, string $date, string $timeFrom, string $timeTo) : Result
The Api merge-slots is a narrow admin-only action without action*(), like
confirm/cancel/bookByAdmin above.
Parameters
- $calendarId : int
- $date : string
- $timeFrom : string
- $timeTo : string
Return values
Resultsave()
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
ResultupdateByAdmin()
Edits a reservation from the modal (name, e-mail, phone, note, state).
public
updateByAdmin(int $id, string $name, string $email, string|null $phone, string|null $note, string $state) : Result
Never changes the time or the time slot; use time-slot/shorten and time-slot/split.
Parameters
- $id : int
- $name : string
- $email : string
- $phone : string|null
- $note : string|null
- $state : string
Return values
ResultupdateColumns()
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
ResultbridgeException()
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
ResultbridgeMessage()
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|nullfailSoftRead()
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
stringresultFromActionResponse()
Builds a `Result` by hand from the flat Api response.
private
resultFromActionResponse(mixed $response) : Result
internalActionConfirm()/internalActionCancel()/internalActionBookByAdmin()/internalActionUpdateByAdmin() return
a flat envelope {success, code, message, reservationId, timeSlotId, state, timeFrom, timeTo} (ReservationPresenter::result() on the Api side), not the standard five-key
Result envelope (it has no data).
IMPORTANT: bookByAdmin needs timeFrom/timeTo because SlotModal::onFillSave() shows
the stored range in the header of its terminal state. Any key this
helper does not copy is silently dropped even when the Api result carries it. ?? null is
harmless for confirm/cancel, whose responses lack those keys.
Parameters
- $response : mixed