WorkItemRepository
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
- addMyComment() : array{success: bool, code: int|null, message: string|null, commentId: int|null, approved: bool, retryAfter?: int}
- Adds a customer comment to the thread of the customer's own work item.
- find() : array<string|int, mixed>
- findAll() : array<string|int, mixed>
- findBy() : array<string|int, mixed>
- findMyComments() : array<string, mixed>
- Returns the comments of a work item for its customer.
- findMyDetail() : array<string, mixed>
- Returns a work item detail for its customer.
- findMyItems() : array<string, mixed>
- Returns the work items of one of the customer's work sheets.
- 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`.
- normalizeCommentEnvelope() : array{success: bool, code: int|null, message: string|null, commentId: int|null, approved: bool, retryAfter?: int}
- 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/work-item'
$bridge read-only
protected
ApiBridge
$bridge
Methods
__construct()
public
__construct(ApiBridge $bridge) : mixed
Parameters
- $bridge : ApiBridge
addMyComment()
Adds a customer comment to the thread of the customer's own work item.
public
addMyComment(int $workItemId, string $text) : array{success: bool, code: int|null, message: string|null, commentId: int|null, approved: bool, retryAfter?: int}
Api narrow action myCommentAdd.
IMPORTANT: the response is not the standard Result envelope (no exception / data keys; flat commentId / approved instead; the Api sends no threadId), so FailSoftReadTrait is deliberately not used. success: false (rate limit, validation, not logged in) is the meaning of the call, not a defect of the response; same as ReservationRepository::book().
Parameters
- $workItemId : int
- $text : string
Return values
array{success: bool, code: int|null, message: string|null, commentId: int|null, approved: bool, retryAfter?: int}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>findMyComments()
Returns the comments of a work item for its customer.
public
findMyComments(int $workItemId[, int|null $offset = null ][, int|null $limit = null ]) : array<string, mixed>
Api narrow action myComments (own comment table; standard items / totalCount / _references). Hydrated by WorkItemMapper::findMyComments().
Parameters
- $workItemId : int
- $offset : int|null = null
- $limit : int|null = null
Return values
array<string, mixed>findMyDetail()
Returns a work item detail for its customer.
public
findMyDetail(int $workItemId) : array<string, mixed>
Api narrow action myDetail. The {data, _references} shape fits EntityHydrator::hydrateWithReferences(), like CompanyRepository::findPresented(). Someone else's, missing or deleted work also returns an empty payload.
Parameters
- $workItemId : int
Return values
array<string, mixed>findMyItems()
Returns the work items of one of the customer's work sheets.
public
findMyItems(int $workListId[, int|null $offset = null ][, int|null $limit = null ]) : array<string, mixed>
Api narrow action myItems: a bridge only, without action*(). Ownership is verified on the server by $workListId
(WorkListManager::isOwnedBy()); someone else's or a missing sheet also returns empty items, so the cases cannot be told apart.
Parameters
- $workListId : int
- $offset : int|null = null
- $limit : int|null = null
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
stringnormalizeCommentEnvelope()
Checks only the response shape, so the caller never receives `mixed` after a transport failure.
private
static normalizeCommentEnvelope(mixed $response) : array{success: bool, code: int|null, message: string|null, commentId: int|null, approved: bool, retryAfter?: int}
Unlike failSoftRead() it does not discard the envelope: success: false passes through unchanged, same as ReservationRepository::normalizeResultEnvelope().
Parameters
- $response : mixed