ApiClientManager
extends Manager
in package
External Api clients: application key authentication and client management.
authenticateKey() resolves the key digest to a cached or DB record and checks the status in
this order: unknown, key revoked, key expired (against the request time, not the cache write
time), application revoked, application disabled, valid. touchLastUsed() writes last_used_at
of the key and the application at most once a minute.
An application may hold several keys, at most MAX_VALID_KEYS valid ones (valid = not revoked
and not expired). A key has an optional future expiry (empty = never expires) that can be set or
cleared later (rotation with overlap). Only an expired or revoked key can be deleted. Request
limits belong to the application, not to the key.
IMPORTANT: only createClient() and issueKey() return the readable key (in data.key). The DB
stores just the digest and it never leaves the Api. Every change evicts the cache records of all
the application keys, so it takes effect immediately.
Tags
Table of Contents
Constants
- EXPIRING_SOON_DAYS : int = 7
- A valid key expiring within this many days has the `expiring` state (highlighted in the admin).
- KEY_LABEL_MAX_LENGTH : int = 100
- KEY_STATE_ACTIVE : string = 'active'
- KEY_STATE_EXPIRED : string = 'expired'
- KEY_STATE_EXPIRING : string = 'expiring'
- KEY_STATE_REVOKED : string = 'revoked'
- LAST_USED_INTERVAL : int = 60
- `last_used_at` is written at most once per this many seconds (per client).
- LIMIT_FIELDS : array<string|int, mixed> = ['limitPerSecond', 'limitPerMinute', 'userLimit...
- LIMIT_MAX : int = 1000000
- MAX_VALID_KEYS : int = 5
- Maximum number of valid (not revoked, not expired) keys per application.
- NAME_MAX_LENGTH : int = 100
- NOTES_MAX_LENGTH : int = 255
- DELETED_IDS_META : string = '__deletedIds'
- Reserved `$meta` key with the ids of the entities being deleted, captured before the first hook.
- EXPIRES_AT_FORMATS : array<string|int, mixed> = ['Y-m-d\TH:i', 'Y-m-d\TH:i:s', 'Y-m-d H:i', 'Y-...
- Accepted expiry input formats: `datetime-local` input (with/without seconds) and the DB format.
Properties
- $service : Service<string|int, TEntity>
- Manager service; subclasses narrow the type (`@property` in the Api/Admin/Front manager).
- $appContext : AppContext
- $assetFormatRegistry : AssetFormatRegistry|null
- Format processor registry for file uploads, used by {@see \App\Core\Traits\Api\Models\Managers\AssetProcessingTrait}.
- $cacheTagInvalidator : CacheTagInvalidator|null
- Post-commit invalidator of the wire-payload query cache (tag bump per entity class).
- $internalCallContext : InternalCallContext|null
- Tells whether the call is an internal bridge call; the single source for reading uploaded items with `path` ({@see readUploadedItem()}).
- $languageContext : LanguageContext|null
- $nonInvalidatingColumns : array<string|int, string>
- Columns whose update does not invalidate the cache: view counters (`registerEvent()` bumps the counter on every pageview). Without this every view would flush the query cache of the whole class; counters are therefore stale up to the TTL. Override per manager by redefining the property.
- $paramsConfig : Config|null
- Neon parameters (`%params%`: server paths and directories), set by the decorator (`decorators.neon`) like `setAppContext()`.
- $presenterContext : PresenterContext
- $settingContext : SettingContext
- $totalCount : int|null
- $useTransactionForDelete : bool
- $useTransactionForSave : bool
- $apiClientKeyConfig : ApiClientKeyConfig
- $apiClientService : ApiClientService
- $authenticatedHashes : array<int, string>
- $rejectedUploads : array<int, array{name: string, reason: string}>
- New uploaded items that the Api did not save during the `save()` that is running right now (type, dimensions, unreadable, …). Filled by {@see recordRejectedUpload()} and returned in `saveInfo.rejectedUploads`.
Methods
- __construct() : mixed
- authenticateKey() : ApiClientAuthentication
- Authenticates the key from the `X-API-Key` header. The caller must answer every failure identically; the status is only for the auth log. `$now` is the request time (tests); expiry is compared with it, never with the time the record was cached.
- createClient() : Result
- Creates a client and its first key. `$values`: `name` (required), `notes`, limits (`null`/empty = default), `roleIds` (missing = default roles), `keyLabel` (optional), `keyExpiresAt` (optional future `Y-m-d\TH:i`). On success `data` = client row + `key` (readable key, returned only here: show it once) + `keyId`.
- delete() : Result
- Deletes the entity or entities by id. Optional hooks (opt-in via `method_exists`, like {@see SaveTrait}) allow cleanup of derived or denormalized state during the delete:
- deleteAll() : Result
- deleteKey() : Result
- Deletes a key, only an expired or revoked one; a valid key must be revoked first (`VALIDATION_FAILED`, `data.field = keys`). On success `data` = client row.
- find() : T|null
-
findAll()
: T> : list
>) - findBy() : T|null
- findDefaultLimits() : array{limitPerSecond: int, limitPerMinute: int, userLimitPerMinute: int, ipLimitPerMinute: int}
- Returns the default limits from `api.clientKey.limits` (form hint: empty = default).
- findDefaultRoleIds() : array<int, int>
- Returns the default roles of a new client: unprivileged roles that apply automatically (guest, registered) or conditionally (owner, receiver). Privileged roles only when explicitly ticked.
- findRelatedIds() : array<int, int>|null
- Returns the ids of target entities that already belong to the record `$parentId` through the relation collection `$property` (for example `('assetRels', 'asset')`, `('fileRels', 'file')`). Reads straight from the database, not through the Api read path (no `UoW::clear()` in the middle of save hooks).
- findRoleOptions() : array<int, array{id: int, code: string, name: string, implicit: string, conditional: bool, privileged: bool, default: bool, required: bool}>
- Returns the roles that can be allowed for a client, with flags: `default` = prefill for a new client, `required` = the guest role every client always has ({@see withRequiredRoles()}).
- findRow() : array<string, mixed>|null
- findRows() : array<int, array<string, mixed>>
- Returns the client overview for the admin including keys (never key digests).
- getAppContext() : AppContext
- getDefaultSkipFields() : array<string|int, string>
- Returns keys that the generic `service->save()` must not copy onto the managed entity.
- getEntityClass() : TEntity>
- Returns the root Doctrine entity class managed by this manager.
- getExternalMetaAllowlist() : array<string|int, string>
- Returns the meta keys allowed through the external HTTP path ({@see \App\Core\Traits\Api\Presenters\SaveTrait::actionSave()}).
- getExternalOwnerData() : array<string, mixed>
- Returns `data` keys that fill the owner from the server when an external save creates a record.
- getExternalRemoteIpData() : array<string, mixed>
- Returns `data` keys that fill the caller's IP from the server when an external save creates a record; sibling of {@see getExternalOwnerData()}.
- getExternalUpdateColumnsAllowlist() : array<string|int, string>
- Returns the columns the external HTTP path may change through {@see \App\Core\Traits\Api\Presenters\SaveTrait::actionUpdateColumns()}.
- getGraphDataKeys() : array<string|int, string>
- Returns the keys an external client may send nested in `data`.
- getLanguageContext() : LanguageContext|null
- getPresenterContext() : PresenterContext
- getServiceClass() : class-string
- Returns the fully qualified service class name, the identity for the per-service rollout allowlist of the wire-payload query cache ({@see \App\Core\Cache\Config::isServiceEnabled()}).
- getSettingContext() : SettingContext
- getSettings() : array<int, array<string, mixed>>
- getTotalCount() : int|null
- initializeAllContexts() : void
- issueKey() : Result
- Issues another key; the other keys stay valid. `$expiresAt` = future `Y-m-d\TH:i`, or `null`/empty = never expires. A revoked application gets `INVALID_STATE`; above `MAX_VALID_KEYS` valid keys it gets `VALIDATION_FAILED` with `data.field = keys`. On success `data` = client row + `key` (readable key, only in this response) + `keyId`.
- registerEvent() : Result
- revoke() : Result
- Permanently revokes a client (irreversible) together with all its not yet revoked keys.
- revokeKey() : Result
- Permanently revokes one key (irreversible); the other keys stay valid. On success `data` = client row.
- save() : Result
- setAppContext() : $this
- setAssetFormatRegistry() : static
- setCacheTagInvalidator() : static
- setEnabled() : Result
- Enables or disables a client. A revoked client cannot be enabled.
- setInternalCallContext() : static
- setLanguageContext() : $this
- setParamsConfig() : static
- setPresenterContext() : $this
- setSettingContext() : $this
- touchLastUsed() : void
- Records the last use of the key and the application, at most once per `LAST_USED_INTERVAL`.
- updateAllRelations() : Result
- updateClient() : Result
- Changes name, notes, limits and (when `roleIds` is in `$values`) the allowed roles. Name, notes and limits are replaced as a whole: a missing limit falls back to the default from `api.clientKey.limits`.
- updateColumn() : Result
- updateColumns() : Result
- updateKey() : Result
- Changes the key label and expiry (future expiry, or `null`/empty = never expires; also later, typically for rotation). The key must belong to the client; a revoked key cannot be changed.
- updateRelations() : Result
- beginRejectedUploads() : array<int, array{name: string, reason: string}>
- Starts a save ({@see save()}): the list of rejected items belongs to this save only; the outer one (a nested save of the same manager) is returned to the caller and restored after the save through {@see finishRejectedUploads()}.
- bumpCacheTags() : void
- Bumps cache tags for the entity after commit: its class, the owned-cascade classes from metadata and the optional `additionalCacheTags()` of the manager.
- bumpCacheTagsExplicit() : void
- Bumps the given classes explicitly (raw-DBAL paths with a cross-entity effect).
- bumpCacheTagsForClass() : void
- Bumps cache tags by class name when there is no instance (bulk delete, `updateColumns()`, raw DBAL, tree operations).
- classCacheTags() : array<string|int, string>
- Returns extra tags for a bump that has no entity, typically tree operations ({@see \App\Core\Traits\Api\Models\Managers\TreeTrait::treeTransaction()}) that rewrite `lft`/`rgt` on many rows.
- finishRejectedUploads() : void
- Ends a save: whatever {@see recordRejectedUpload()} wrote during it is added to the data of a successful result as `saveInfo.rejectedUploads` (the Api presenter passes it on to the caller, the admin builds a warning from it). A rejected item does not fail the save; the accepted files stay.
- getDeletedId() : int|null
- Returns the id `$entity` had before the delete, from the snapshot in `$meta` that {@see delete()} hands to every hook. Null for an entity the snapshot does not know (not loaded by this delete, or without a simple id).
- getService() : Service<string|int, TEntity>
- Returns the service backing the manager traits.
- readUploadedItem() : string|null
- Reads the content of an uploaded item (`{name, data}` base64 or `{name, path}` from the dropzone) through the single reader {@see UploadedItem}.
- recordRejectedUpload() : void
- Records a new uploaded item that the save skipped ({@see UploadRejection} `REASON_*`).
- buildKeyRow() : array{id: int, keyPrefix: string, label: string|null, createdAt: string|null, expiresAt: string|null, revokedAt: string|null, lastUsedAt: string|null, state: string}
- Builds the key row: `id`, `keyPrefix`, `label`, `createdAt`, `expiresAt`, `revokedAt`, `lastUsedAt` (`Y-m-d H:i:s` in the application time zone) and `state` (active, expiring, expired, revoked).
- buildRow() : array<string, mixed>
- Builds the client row for the admin, without key digests; adds `state` (`enabled` / `disabled` / `revoked`), `roleIds` (allowed roles), `keys` (keys with state, {@see buildKeyRow()}) and `activeKeyCount` (valid keys: `active` + `expiring`).
- bumpDeleteCacheTags() : void
- Post-commit bump after a delete. With entities it goes through {@see \App\Core\Base\BaseManager::bumpCacheTags()}, which also collects `additionalCacheTags()` (Comment → CommentThread); without them it falls back to bumping the manager class itself, the original behavior.
- captureDeletedIds() : WeakMap<object, int>
- Keys the ids by the loaded entity objects, not by the input ids: an input id that loaded nothing must not shift the pairing. A weak map, so the snapshot never keeps an entity alive.
- changeClient() : Result
- Shared state change flow: find the client, run the UPDATE (it carries the "not revoked" condition), evict the cache records of all its keys. 0 changed rows for an existing client means the client is revoked.
- columnsInvalidateCache() : bool
- deleteBatch() : Result
- Bulk delete of a list of ids as one transaction. `Service::deleteAll()` flushes per entity; in autocommit the rows deleted before a database failure would stay deleted while the caller got either an escaped `EntityManagerClosed` or an "OK" with an error text. Here the service stops at the technical failure, this wrapper rolls the whole batch back and returns the failure Result with `deletedCount = 0` and `rolledBack = true`: nothing of the batch is durable and nothing is attempted over the closed EntityManager. A domain partial success (missing ids) keeps the existing contract and is committed.
- findKey() : ApiClientKeyRow|Result
- Returns the client key by id, or `ITEM_NOT_FOUND` (unknown client, foreign or unknown key).
- invalid() : Result
- isAssetPathAllowed() : bool
- Checks only entities composing {@see AssetPathTrait}; the trait is the allowlist of "relative file path" columns, other `assetPath`-like fields are untouched.
- isDefaultRole() : bool
- isRequiredRole() : bool
- keyState() : string
- Returns the key state at `$now`: revoked, expired, expiring within `EXPIRING_SOON_DAYS` days, or active.
- loadEntitiesForCacheTags() : array<int, object>
- Loads the entities being deleted only to find out their `additionalCacheTags()`. Fail-soft: what cannot be loaded is simply missing and the bump falls back to the class; it must never stop the delete.
- normalizeKeyValues() : DateTimeImmutable|null}|Result
- Normalizes the key label and expiry input. Label: optional, at most `KEY_LABEL_MAX_LENGTH` characters. Expiry: `Y-m-d\TH:i` (also with seconds, or a space instead of `T`), in the application time zone, must be in the future; empty = never expires. Errors are `VALIDATION_FAILED` with `data.field` `keyLabel` / `keyExpiresAt`.
- normalizeRoleIds() : array<int, int>|null
-
normalizeValues()
: array{values: array{name: string, notes: string|null, limitPerSecond: int|null, limitPerMinute: int|null, userLimitPerMinute: int|null, ipLimitPerMinute: int|null}, roleIds: list
|null}|Result - parseExpiresAt() : DateTimeImmutable|null
- Strict parser: exact format, no silent normalization of `2026-02-30` to `2026-03-02`.
- rollbackBatch() : void
- saveWithHooks() : Result
- Runs the save itself: transaction, `beforeSave` / `afterSave` / `completedSave`, tree, cache.
- tooManyKeys() : Result
- usesAssetPathTrait() : bool
- withRequiredRoles() : array<int, int>
- Returns the allowed roles plus the required guest role (`implicit = anonymous`).
Constants
EXPIRING_SOON_DAYS
A valid key expiring within this many days has the `expiring` state (highlighted in the admin).
public
int
EXPIRING_SOON_DAYS
= 7
KEY_LABEL_MAX_LENGTH
public
int
KEY_LABEL_MAX_LENGTH
= 100
KEY_STATE_ACTIVE
public
string
KEY_STATE_ACTIVE
= 'active'
KEY_STATE_EXPIRED
public
string
KEY_STATE_EXPIRED
= 'expired'
KEY_STATE_EXPIRING
public
string
KEY_STATE_EXPIRING
= 'expiring'
KEY_STATE_REVOKED
public
string
KEY_STATE_REVOKED
= 'revoked'
LAST_USED_INTERVAL
`last_used_at` is written at most once per this many seconds (per client).
public
int
LAST_USED_INTERVAL
= 60
LIMIT_FIELDS
public
array<string|int, mixed>
LIMIT_FIELDS
= ['limitPerSecond', 'limitPerMinute', 'userLimitPerMinute', 'ipLimitPerMinute']
LIMIT_MAX
public
int
LIMIT_MAX
= 1000000
MAX_VALID_KEYS
Maximum number of valid (not revoked, not expired) keys per application.
public
int
MAX_VALID_KEYS
= 5
NAME_MAX_LENGTH
public
int
NAME_MAX_LENGTH
= 100
NOTES_MAX_LENGTH
public
int
NOTES_MAX_LENGTH
= 255
DELETED_IDS_META
Reserved `$meta` key with the ids of the entities being deleted, captured before the first hook.
protected
string
DELETED_IDS_META
= '__deletedIds'
Read it only through getDeletedId().
EXPIRES_AT_FORMATS
Accepted expiry input formats: `datetime-local` input (with/without seconds) and the DB format.
private
array<string|int, mixed>
EXPIRES_AT_FORMATS
= ['Y-m-d\TH:i', 'Y-m-d\TH:i:s', 'Y-m-d H:i', 'Y-m-d H:i:s']
Properties
$service
Manager service; subclasses narrow the type (`@property` in the Api/Admin/Front manager).
public
Service<string|int, TEntity>
$service
$appContext
protected
AppContext
$appContext
$assetFormatRegistry
Format processor registry for file uploads, used by {@see \App\Core\Traits\Api\Models\Managers\AssetProcessingTrait}.
protected
AssetFormatRegistry|null
$assetFormatRegistry
= null
Set by a decorator (decorators.neon) like setParamsConfig(): more than ten managers
process assets and each has its own constructor, so constructor injection would touch all
of them.
$cacheTagInvalidator
Post-commit invalidator of the wire-payload query cache (tag bump per entity class).
protected
CacheTagInvalidator|null
$cacheTagInvalidator
= null
Set by the decorator (decorators.neon) like setParamsConfig(). Nullable and
fail-open: without wiring (or without Redis) a bump is a no-op.
$internalCallContext
Tells whether the call is an internal bridge call; the single source for reading uploaded items with `path` ({@see readUploadedItem()}).
protected
InternalCallContext|null
$internalCallContext
= null
Only ApiBridge::internalCall() sets it, never the payload and not
the RBAC guard, so the emergency apiRbac.internalMode: off cannot disable it. Set by a
decorator like setAssetFormatRegistry(). Without it (direct manager call from cron or a
test) the call counts as external.
$languageContext
protected
LanguageContext|null
$languageContext
= NULL
$nonInvalidatingColumns
Columns whose update does not invalidate the cache: view counters (`registerEvent()` bumps the counter on every pageview). Without this every view would flush the query cache of the whole class; counters are therefore stale up to the TTL. Override per manager by redefining the property.
protected
array<string|int, string>
$nonInvalidatingColumns
= ['views', 'viewsList', 'viewsDetail']
Covers all view counters across modules: views (Blog Article), viewsList (list
impression of Advert/Message) and viewsDetail (detail view of Advert/Message,
registerEvent() in the *DetailTraits). IMPORTANT: viewsDetail must stay in the
list, otherwise every open of an advert/post detail would invalidate all lists of the
class.
$paramsConfig
Neon parameters (`%params%`: server paths and directories), set by the decorator (`decorators.neon`) like `setAppContext()`.
protected
Config|null
$paramsConfig
= null
Write logic (asset directories) reads paths from here, not from getSettings() or the
setting context, which may be filled by the client without server paths. The property
cannot be named $config: it collides with the promoted $config in some managers.
$presenterContext
protected
PresenterContext
$presenterContext
$settingContext
protected
SettingContext
$settingContext
$totalCount
protected
int|null
$totalCount
= null
$useTransactionForDelete
protected
bool
$useTransactionForDelete
= true
$useTransactionForSave
protected
bool
$useTransactionForSave
= true
$apiClientKeyConfig read-only
private
ApiClientKeyConfig
$apiClientKeyConfig
$apiClientService read-only
private
ApiClientService
$apiClientService
$authenticatedHashes
private
array<int, string>
$authenticatedHashes
= []
key id => digest authenticated in this request (for the cache write)
$rejectedUploads
New uploaded items that the Api did not save during the `save()` that is running right now (type, dimensions, unreadable, …). Filled by {@see recordRejectedUpload()} and returned in `saveInfo.rejectedUploads`.
private
array<int, array{name: string, reason: string}>
$rejectedUploads
= []
Methods
__construct()
public
__construct(ApiClientService $apiClientService, ApiClientKeyConfig $apiClientKeyConfig) : mixed
Parameters
- $apiClientService : ApiClientService
- $apiClientKeyConfig : ApiClientKeyConfig
authenticateKey()
Authenticates the key from the `X-API-Key` header. The caller must answer every failure identically; the status is only for the auth log. `$now` is the request time (tests); expiry is compared with it, never with the time the record was cached.
public
authenticateKey(string|null $rawKey[, DateTimeImmutable|null $now = null ]) : ApiClientAuthentication
Parameters
- $rawKey : string|null
- $now : DateTimeImmutable|null = null
Return values
ApiClientAuthenticationcreateClient()
Creates a client and its first key. `$values`: `name` (required), `notes`, limits (`null`/empty = default), `roleIds` (missing = default roles), `keyLabel` (optional), `keyExpiresAt` (optional future `Y-m-d\TH:i`). On success `data` = client row + `key` (readable key, returned only here: show it once) + `keyId`.
public
createClient(array<string, mixed> $values) : Result
Parameters
- $values : array<string, mixed>
Return values
Resultdelete()
Deletes the entity or entities by id. Optional hooks (opt-in via `method_exists`, like {@see SaveTrait}) allow cleanup of derived or denormalized state during the delete:
public
delete(int|array<string|int, mixed> $id[, array<string, mixed> $meta = [] ]) : Result
beforeDelete(array $entities, array $meta): ?Resultruns before the delete (validation or capturing context while the rows exist). A failed Result means rollback and return. Its data flows intoafterDeleteunder$meta['__beforeDelete'].afterDelete(array $entities, Result $result, array $meta): ?Resultruns after the delete, still in the transaction. It is only for recomputing derived state from the remaining rows (toped_until, member_until, county), idempotent and reversible. A failure rolls back the delete itself (atomicity). It is also the place for the mandatory delete of dependents through a foreign manager (comment, rating and message threads): an owner still managed in the unit of work references them, so they must go after its row, never before it inbeforeDelete(collect their ids there). Additive or irreversible effects (credits, e-mails, invoices) do not belong here, only intocompletedDelete.completedDelete(array $entities, Result $result, array $meta): voidruns best effort after the commit, outside the transaction; an exception is only logged (the delete stays).completedAssetCleanup(array $entities, Result $result, array $meta): voidruns best effort after the commit and releases theAssetrows and files the deleted entity owned. The body is in AssetProcessingTrait; opt-in isownedAssetIds(object $entity): arrayon the manager, without it the hook does not run.
IMPORTANT: the cleanup has its own name instead of completedDelete() because many Api managers define
completedDelete() themselves and a class method overrides a trait method without a warning, so the
cleanup would silently be missing in them.
IMPORTANT: a soft delete (deleted = 1) goes through save(), not here; assets must not be released
there because the record can be restored.
$entities are the entities loaded before the delete (after the DELETE the row is gone, but the PHP
object keeps the data, such as FKs for the recomputation).
IMPORTANT: the id is the exception. Doctrine nulls the id of a removed instance on flush(), so a
hook must not rely on getId() once the delete ran (today only the read UoW::clear() in the
service find() hands the preloaded entities over detached and keeps their id). Every hook therefore
gets the ids captured before beforeDelete under the reserved key DELETED_IDS_META, keyed by
the loaded entity object (an input id that loaded nothing has no entry); read it through
getDeletedId(). The key is always set here, so a caller-supplied value never survives.
Without hooks it behaves exactly as before (no preloading, no transaction). NOTE: deleteAll() (bulk) and the tree deleteNode take another
path and do not trigger these hooks.
Parameters
- $id : int|array<string|int, mixed>
- $meta : array<string, mixed> = []
Return values
ResultdeleteAll()
public
deleteAll([array<string|int, mixed> $filters = [] ]) : Result
Parameters
- $filters : array<string|int, mixed> = []
Return values
ResultdeleteKey()
Deletes a key, only an expired or revoked one; a valid key must be revoked first (`VALIDATION_FAILED`, `data.field = keys`). On success `data` = client row.
public
deleteKey(int $clientId, int $keyId) : Result
Parameters
- $clientId : int
- $keyId : int
Return values
Resultfind()
public
find(int $id[, string|array<string|int, mixed> $includes = [] ]) : T|null
Parameters
- $id : int
- $includes : string|array<string|int, mixed> = []
Return values
T|nullfindAll()
public
findAll([array<string|int, mixed>|null $includes = [] ][, 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 ]) : T> : list>)
Parameters
- $includes : array<string|int, mixed>|null = []
- $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
Return values
T> : listentities, or raw rows when $columns is set
findBy()
public
findBy([array<string|int, mixed>|null $filters = [] ][, string|array<string|int, mixed> $includes = [] ]) : T|null
Parameters
- $filters : array<string|int, mixed>|null = []
- $includes : string|array<string|int, mixed> = []
Return values
T|nullfindDefaultLimits()
Returns the default limits from `api.clientKey.limits` (form hint: empty = default).
public
findDefaultLimits() : array{limitPerSecond: int, limitPerMinute: int, userLimitPerMinute: int, ipLimitPerMinute: int}
Return values
array{limitPerSecond: int, limitPerMinute: int, userLimitPerMinute: int, ipLimitPerMinute: int}findDefaultRoleIds()
Returns the default roles of a new client: unprivileged roles that apply automatically (guest, registered) or conditionally (owner, receiver). Privileged roles only when explicitly ticked.
public
findDefaultRoleIds() : array<int, int>
Return values
array<int, int>findRelatedIds()
Returns the ids of target entities that already belong to the record `$parentId` through the relation collection `$property` (for example `('assetRels', 'asset')`, `('fileRels', 'file')`). Reads straight from the database, not through the Api read path (no `UoW::clear()` in the middle of save hooks).
public
findRelatedIds(int $parentId, string $property, string $targetAssociation) : array<int, int>|null
Parameters
- $parentId : int
- $property : string
- $targetAssociation : string
Return values
array<int, int>|null —null when it cannot be determined (collection mapping missing / database error)
findRoleOptions()
Returns the roles that can be allowed for a client, with flags: `default` = prefill for a new client, `required` = the guest role every client always has ({@see withRequiredRoles()}).
public
findRoleOptions() : array<int, array{id: int, code: string, name: string, implicit: string, conditional: bool, privileged: bool, default: bool, required: bool}>
Return values
array<int, array{id: int, code: string, name: string, implicit: string, conditional: bool, privileged: bool, default: bool, required: bool}>findRow()
public
findRow(int $clientId) : array<string, mixed>|null
Parameters
- $clientId : int
Return values
array<string, mixed>|nullfindRows()
Returns the client overview for the admin including keys (never key digests).
public
findRows() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>> —see buildRow()
getAppContext()
public
getAppContext() : AppContext
Return values
AppContextgetDefaultSkipFields()
Returns keys that the generic `service->save()` must not copy onto the managed entity.
public
getDefaultSkipFields() : array<string|int, string>
The manager's own afterSave()/beforeSave() sync trait handles them through $meta,
not through the object graph. Backed by an optional protected per-manager property.
The write Api endpoint (SaveTrait::internalActionSave())
also uses this accessor to strip the same keys from $data before hydration, because
defaultSkipFields alone does not protect hydration.
Return values
array<string|int, string>getEntityClass()
Returns the root Doctrine entity class managed by this manager.
public
getEntityClass() : TEntity>
The write Api endpoint (SaveTrait) takes it from here instead of the request, so a client cannot choose the instantiated PHP class.
Return values
TEntity>getExternalMetaAllowlist()
Returns the meta keys allowed through the external HTTP path ({@see \App\Core\Traits\Api\Presenters\SaveTrait::actionSave()}).
public
getExternalMetaAllowlist() : array<string|int, string>
The internal path (ApiBridge::internalCall() calling internalActionSave() directly, admin and
front) is not limited by this allowlist and reads $meta unchanged. The default is an
empty array, so external meta is dropped entirely; actionSave() is reachable through
HTTP routing regardless of ApiBridge, hence the strip. Override per manager with the
protected property $externalMetaAllowlist, analogous to self::getDefaultSkipFields().
Return values
array<string|int, string>getExternalOwnerData()
Returns `data` keys that fill the owner from the server when an external save creates a record.
public
getExternalOwnerData(int $userId) : array<string, mixed>
The default [] means the domain has no owner or must not be created through external
save (Order uses the dedicated checkout action, User registers another way). On
INSERT there is nothing to own, so the owner cannot be verified, only determined: the owner
field is #[ExternalReadonly] (the strip removes it from the payload) and
SaveTrait::applyExternalOwner() then fills it from
the JWT, so the client value never reaches hydration.
IMPORTANT: return the key that matches the column mapping, otherwise the owner is silently not written:
Watchdog/Comment/Rating/Message: scalar column,['userId' => $userId];Advert(Bazaar/Comcat): mapped column,['insertUserId' => $userId];- Bazaar
Response/AdvertFollower: the scalaruserIdhas an#[ORM\AttributeOverride]withinsertable: false, updatable: falsein the Api leaf and the column belongs to the association$user, so['user' => ['id' => $userId]]; ComcatResponsehas no$userassociation, so there it is['userId' => $userId]; Complaint: the owner is the association$user,['user' => ['id' => $userId]].
['id' => X] is a reference that hydrateForPersist() looks up in the DB
(OrmEntityHydrator::isReference()). Called only on the
external path and only on INSERT; on UPDATE it would make whoever saves a foreign record
its owner.
Parameters
- $userId : int
-
identity from the JWT (never from the request)
Return values
array<string, mixed>getExternalRemoteIpData()
Returns `data` keys that fill the caller's IP from the server when an external save creates a record; sibling of {@see getExternalOwnerData()}.
public
getExternalRemoteIpData(string $ip) : array<string, mixed>
The IP field is #[ExternalReadonly], so the external strip removes it and the client
cannot forge it. Without filling, an external insert would have no IP and the
"anonymous by IP" deduplication and per-IP manager limits would silently stop working.
SaveTrait::applyExternalRemoteIp() fills it from
IRequest::getRemoteAddress(), never from the request. The default [] means the entity
carries no IP; overrides return the entity field name (['insertIp' => $ip]).
Parameters
- $ip : string
Return values
array<string, mixed>getExternalUpdateColumnsAllowlist()
Returns the columns the external HTTP path may change through {@see \App\Core\Traits\Api\Presenters\SaveTrait::actionUpdateColumns()}.
public
getExternalUpdateColumnsAllowlist() : array<string|int, string>
updateColumn on a to-many relation is DELETE-all plus INSERT, so without this filter an
external POST with values={userRoles: [...]} would bypass the strip/guard of the save
path (privilege escalation). The internal path (ApiBridge::internalCall() calling
internalActionUpdateColumns() directly) is not limited. The default is an empty array, so
external updateColumns is rejected entirely. Override with the protected property
$externalUpdateColumnsAllowlist.
Return values
array<string|int, string>getGraphDataKeys()
Returns the keys an external client may send nested in `data`.
public
getGraphDataKeys() : array<string|int, string>
Before hydration the write Api endpoint
(SaveTrait::internalActionSave()) moves them from $data to
$meta, where the manager's own afterSave()/beforeSave() sync trait reads them (the
same mechanism as internal meta). When the client also sends the same key explicitly in
meta, meta wins (compatibility with admin, e.g. the categoryRels collision on
Advert). Backed by an optional protected per-manager property, like
self::getDefaultSkipFields().
IMPORTANT: promoting a key here does not make its content safe to write as received. When
the key carries a sensitive field that the server otherwise dictates (typically a payment
or approval flag), the manager must overwrite or verify it server-side on the external
path in beforeSave()/afterSave() before its sync trait reads it; otherwise the client
sets it itself (privilege escalation). The external path is recognized by
$meta['__external'] === true, which only SaveTrait::actionSave() sets (never
internalActionSave() alone), so internal calls never get the marker. Example: Bazaar
Advert.categoryRels is persisted through the object graph (owned collection outside
$graphDataKeys); a client could mark paid itself and get a paid advert without
payment, so AdvertManager::beforeSave() overwrites it through
CategoryRelsPaidSanitizationTrait::sanitizeExternalCategoryRelsPaid() before flush.
Return values
array<string|int, string>getLanguageContext()
public
getLanguageContext() : LanguageContext|null
Return values
LanguageContext|nullgetPresenterContext()
public
getPresenterContext() : PresenterContext
Return values
PresenterContextgetServiceClass()
Returns the fully qualified service class name, the identity for the per-service rollout allowlist of the wire-payload query cache ({@see \App\Core\Cache\Config::isServiceEnabled()}).
public
getServiceClass() : class-string
The cache is controlled at the Api presenter boundary through this identity.
Return values
class-stringgetSettingContext()
public
getSettingContext() : SettingContext
Return values
SettingContextgetSettings()
public
getSettings() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>getTotalCount()
public
getTotalCount() : int|null
Return values
int|nullinitializeAllContexts()
public
initializeAllContexts() : void
issueKey()
Issues another key; the other keys stay valid. `$expiresAt` = future `Y-m-d\TH:i`, or `null`/empty = never expires. A revoked application gets `INVALID_STATE`; above `MAX_VALID_KEYS` valid keys it gets `VALIDATION_FAILED` with `data.field = keys`. On success `data` = client row + `key` (readable key, only in this response) + `keyId`.
public
issueKey(int $clientId, string|null $label, string|null $expiresAt) : Result
Parameters
- $clientId : int
- $label : string|null
- $expiresAt : string|null
Return values
ResultregisterEvent()
public
registerEvent(array<string|int, int> $ids, class-string $entityClass, string $property) : Result
Parameters
- $ids : array<string|int, int>
- $entityClass : class-string
-
entity used to translate the property into a column in the expression
- $property : string
Return values
Resultrevoke()
Permanently revokes a client (irreversible) together with all its not yet revoked keys.
public
revoke(int $clientId) : Result
Parameters
- $clientId : int
Return values
ResultrevokeKey()
Permanently revokes one key (irreversible); the other keys stay valid. On success `data` = client row.
public
revokeKey(int $clientId, int $keyId) : Result
Parameters
- $clientId : int
- $keyId : int
Return values
Resultsave()
public
save(TEntity $entity[, array<string, mixed> $meta = [] ][, array<int, string> $skipFields = [] ]) : Result
Parameters
- $entity : TEntity
- $meta : array<string, mixed> = []
- $skipFields : array<int, string> = []
Return values
ResultsetAppContext()
public
setAppContext(AppContext $appContext) : $this
Parameters
- $appContext : AppContext
Return values
$thissetAssetFormatRegistry()
public
setAssetFormatRegistry(AssetFormatRegistry $assetFormatRegistry) : static
Parameters
- $assetFormatRegistry : AssetFormatRegistry
Return values
staticsetCacheTagInvalidator()
public
setCacheTagInvalidator(CacheTagInvalidator $cacheTagInvalidator) : static
Parameters
- $cacheTagInvalidator : CacheTagInvalidator
Return values
staticsetEnabled()
Enables or disables a client. A revoked client cannot be enabled.
public
setEnabled(int $clientId, bool $enabled) : Result
Parameters
- $clientId : int
- $enabled : bool
Return values
ResultsetInternalCallContext()
public
setInternalCallContext(InternalCallContext $internalCallContext) : static
Parameters
- $internalCallContext : InternalCallContext
Return values
staticsetLanguageContext()
public
setLanguageContext(LanguageContext|null $languageContext) : $this
Parameters
- $languageContext : LanguageContext|null
Return values
$thissetParamsConfig()
public
setParamsConfig(Config $paramsConfig) : static
Parameters
- $paramsConfig : Config
Return values
staticsetPresenterContext()
public
setPresenterContext(PresenterContext $presenterContext) : $this
Parameters
- $presenterContext : PresenterContext
Return values
$thissetSettingContext()
public
setSettingContext(SettingContext $settingContext) : $this
Parameters
- $settingContext : SettingContext
Return values
$thistouchLastUsed()
Records the last use of the key and the application, at most once per `LAST_USED_INTERVAL`.
public
touchLastUsed(ApiClientIdentity $client[, DateTimeImmutable|null $now = null ]) : void
The timestamps from the cached record decide (no I/O until the interval elapses); every UPDATE carries the same condition, so concurrent processes write at most one row. A failed write does not stop the request.
Parameters
- $client : ApiClientIdentity
- $now : DateTimeImmutable|null = null
updateAllRelations()
public
updateAllRelations(int|array<string|int, mixed> $entityId, string $property, array<string, mixed> $values) : Result
Parameters
- $entityId : int|array<string|int, mixed>
-
id, or a list of ids / composite-id arrays
- $property : string
- $values : array<string, mixed>
-
relation property name => value set on every row
Return values
ResultupdateClient()
Changes name, notes, limits and (when `roleIds` is in `$values`) the allowed roles. Name, notes and limits are replaced as a whole: a missing limit falls back to the default from `api.clientKey.limits`.
public
updateClient(int $clientId, array<string, mixed> $values) : Result
Parameters
- $clientId : int
- $values : array<string, mixed>
Return values
ResultupdateColumn()
public
updateColumn(int|array<string|int, mixed> $entityId, string $property, mixed $value) : Result
Parameters
- $entityId : int|array<string|int, mixed>
-
id, or a list of ids / composite-id arrays
- $property : string
- $value : mixed
Return values
ResultupdateColumns()
public
updateColumns(int|array<string|int, mixed> $entityId, array<string, mixed> $values) : Result
Parameters
- $entityId : int|array<string|int, mixed>
-
id, or a list of ids / composite-id arrays
- $values : array<string, mixed>
-
property name => new value
Return values
ResultupdateKey()
Changes the key label and expiry (future expiry, or `null`/empty = never expires; also later, typically for rotation). The key must belong to the client; a revoked key cannot be changed.
public
updateKey(int $clientId, int $keyId, string|null $label, string|null $expiresAt) : Result
Extending an expired key makes it valid again, so the valid key cap applies here too. On success
data = client row.
Parameters
- $clientId : int
- $keyId : int
- $label : string|null
- $expiresAt : string|null
Return values
ResultupdateRelations()
public
updateRelations(int|array<string|int, mixed> $entityId, string $property, array<string|int, object> $relationEntities) : Result
Parameters
- $entityId : int|array<string|int, mixed>
-
id, or a list of ids / composite-id arrays
- $property : string
- $relationEntities : array<string|int, object>
-
relation entities with updated values
Return values
ResultbeginRejectedUploads()
Starts a save ({@see save()}): the list of rejected items belongs to this save only; the outer one (a nested save of the same manager) is returned to the caller and restored after the save through {@see finishRejectedUploads()}.
protected
beginRejectedUploads() : array<int, array{name: string, reason: string}>
Return values
array<int, array{name: string, reason: string}> —the outer save's list
bumpCacheTags()
Bumps cache tags for the entity after commit: its class, the owned-cascade classes from metadata and the optional `additionalCacheTags()` of the manager.
protected
bumpCacheTags(object $entity) : void
Fail-open (the invalidator swallows exceptions). Called from the manager Save/Delete/Tree traits after the commit.
Parameters
- $entity : object
bumpCacheTagsExplicit()
Bumps the given classes explicitly (raw-DBAL paths with a cross-entity effect).
protected
bumpCacheTagsExplicit(array<string|int, string> $classes) : void
Parameters
- $classes : array<string|int, string>
bumpCacheTagsForClass()
Bumps cache tags by class name when there is no instance (bulk delete, `updateColumns()`, raw DBAL, tree operations).
protected
bumpCacheTagsForClass(class-string $rootClass[, array<string|int, string> $extraTags = [] ]) : void
Bumps the root class and its owned-cascade classes.
Parameters
- $rootClass : class-string
- $extraTags : array<string|int, string> = []
classCacheTags()
Returns extra tags for a bump that has no entity, typically tree operations ({@see \App\Core\Traits\Api\Models\Managers\TreeTrait::treeTransaction()}) that rewrite `lft`/`rgt` on many rows.
protected
classCacheTags() : array<string|int, string>
IMPORTANT: additionalCacheTags(object) receives an entity, so a class-level bump cannot
use it; without this hook a delete would lose the cross-entity tag (Comment to
CommentThread). A manager whose cross-entity tag does not depend on a particular
entity returns it here.
NOTE: unlike additionalCacheTags(), this hook is declared (with an empty default)
instead of being an opt-in through method_exists(); method_exists() is always true in
a manager that has the method, which phpstan reports as alreadyNarrowedType.
Return values
array<string|int, string>finishRejectedUploads()
Ends a save: whatever {@see recordRejectedUpload()} wrote during it is added to the data of a successful result as `saveInfo.rejectedUploads` (the Api presenter passes it on to the caller, the admin builds a warning from it). A rejected item does not fail the save; the accepted files stay.
protected
finishRejectedUploads(Result|null $result, array<int, array{name: string, reason: string}> $outer) : void
Parameters
- $result : Result|null
- $outer : array<int, array{name: string, reason: string}>
-
list from beginRejectedUploads()
getDeletedId()
Returns the id `$entity` had before the delete, from the snapshot in `$meta` that {@see delete()} hands to every hook. Null for an entity the snapshot does not know (not loaded by this delete, or without a simple id).
protected
getDeletedId(array<string, mixed> $meta, object $entity) : int|null
Parameters
- $meta : array<string, mixed>
- $entity : object
Return values
int|nullgetService()
Returns the service backing the manager traits.
protected
getService() : Service<string|int, TEntity>
Return values
Service<string|int, TEntity>readUploadedItem()
Reads the content of an uploaded item (`{name, data}` base64 or `{name, path}` from the dropzone) through the single reader {@see UploadedItem}.
protected
readUploadedItem(array<string|int, mixed> $item[, bool $strictBase64 = true ][, int|null $maxBytes = null ]) : string|null
Call it right before processing and release the result before the next item, so that
files never meet in memory. A path is accepted only during an internal bridge call
($internalCallContext) and only inside the dropzone root. A rejected path is logged
to the auth channel and null is returned; callers treat it like unreadable data (skip
the item or refuse the save).
Parameters
- $item : array<string|int, mixed>
- $strictBase64 : bool = true
-
false for callers that decode loosely (
base64_decode($x)) - $maxBytes : int|null = null
-
size limit; for
pathit is checked before reading
Return values
string|nullrecordRejectedUpload()
Records a new uploaded item that the save skipped ({@see UploadRejection} `REASON_*`).
protected
recordRejectedUpload(mixed $name, string $reason) : void
Called by the places that drop an item (processOrderedAssets(), advert attachments,
product set gallery).
Parameters
- $name : mixed
- $reason : string
buildKeyRow()
Builds the key row: `id`, `keyPrefix`, `label`, `createdAt`, `expiresAt`, `revokedAt`, `lastUsedAt` (`Y-m-d H:i:s` in the application time zone) and `state` (active, expiring, expired, revoked).
private
static buildKeyRow(ApiClientKeyRow $key, DateTimeImmutable $now) : array{id: int, keyPrefix: string, label: string|null, createdAt: string|null, expiresAt: string|null, revokedAt: string|null, lastUsedAt: string|null, state: string}
Parameters
- $key : ApiClientKeyRow
- $now : DateTimeImmutable
Return values
array{id: int, keyPrefix: string, label: string|null, createdAt: string|null, expiresAt: string|null, revokedAt: string|null, lastUsedAt: string|null, state: string}buildRow()
Builds the client row for the admin, without key digests; adds `state` (`enabled` / `disabled` / `revoked`), `roleIds` (allowed roles), `keys` (keys with state, {@see buildKeyRow()}) and `activeKeyCount` (valid keys: `active` + `expiring`).
private
static buildRow(ApiClientRow $row, array<int, int> $roleIds, array<int, ApiClientKeyRow> $keys, DateTimeImmutable $now) : array<string, mixed>
Parameters
- $row : ApiClientRow
- $roleIds : array<int, int>
- $keys : array<int, ApiClientKeyRow>
- $now : DateTimeImmutable
Return values
array<string, mixed>bumpDeleteCacheTags()
Post-commit bump after a delete. With entities it goes through {@see \App\Core\Base\BaseManager::bumpCacheTags()}, which also collects `additionalCacheTags()` (Comment → CommentThread); without them it falls back to bumping the manager class itself, the original behavior.
private
bumpDeleteCacheTags(array<int, object> $entities) : void
Parameters
- $entities : array<int, object>
captureDeletedIds()
Keys the ids by the loaded entity objects, not by the input ids: an input id that loaded nothing must not shift the pairing. A weak map, so the snapshot never keeps an entity alive.
private
captureDeletedIds(array<int, object> $entities) : WeakMap<object, int>
Parameters
- $entities : array<int, object>
Return values
WeakMap<object, int>changeClient()
Shared state change flow: find the client, run the UPDATE (it carries the "not revoked" condition), evict the cache records of all its keys. 0 changed rows for an existing client means the client is revoked.
private
changeClient(int $clientId, callable(DateTimeImmutable): int $update) : Result
Parameters
- $clientId : int
- $update : callable(DateTimeImmutable): int
Return values
ResultcolumnsInvalidateCache()
private
columnsInvalidateCache(array<int, string> $columns) : bool
Parameters
- $columns : array<int, string>
Return values
booldeleteBatch()
Bulk delete of a list of ids as one transaction. `Service::deleteAll()` flushes per entity; in autocommit the rows deleted before a database failure would stay deleted while the caller got either an escaped `EntityManagerClosed` or an "OK" with an error text. Here the service stops at the technical failure, this wrapper rolls the whole batch back and returns the failure Result with `deletedCount = 0` and `rolledBack = true`: nothing of the batch is durable and nothing is attempted over the closed EntityManager. A domain partial success (missing ids) keeps the existing contract and is committed.
private
deleteBatch(array<int, int|string|array<string|int, mixed>> $ids) : Result
Transaction ownership: the wrapper only opens its own level; inside a caller's transaction a rollback
here marks the caller's transaction rollback-only, so its final commit rolls the whole scope back
(TransactionManager counter contract, the same as the hooked delete() path).
Parameters
- $ids : array<int, int|string|array<string|int, mixed>>
Return values
ResultfindKey()
Returns the client key by id, or `ITEM_NOT_FOUND` (unknown client, foreign or unknown key).
private
findKey(int $clientId, int $keyId) : ApiClientKeyRow|Result
Parameters
- $clientId : int
- $keyId : int
Return values
ApiClientKeyRow|Resultinvalid()
private
static invalid(string $field, string $message) : Result
Parameters
- $field : string
- $message : string
Return values
ResultisAssetPathAllowed()
Checks only entities composing {@see AssetPathTrait}; the trait is the allowlist of "relative file path" columns, other `assetPath`-like fields are untouched.
private
isAssetPathAllowed(BaseEntity $entity) : bool
Parameters
- $entity : BaseEntity
Return values
boolisDefaultRole()
private
static isDefaultRole(array{implicit: string, conditional: bool, privileged: bool} $role) : bool
Parameters
- $role : array{implicit: string, conditional: bool, privileged: bool}
Return values
boolisRequiredRole()
private
static isRequiredRole(array{implicit: string} $role) : bool
Parameters
- $role : array{implicit: string}
Return values
boolkeyState()
Returns the key state at `$now`: revoked, expired, expiring within `EXPIRING_SOON_DAYS` days, or active.
private
static keyState(array{expiresAt: string|null, revokedAt: string|null} $key, DateTimeImmutable $now) : string
Parameters
- $key : array{expiresAt: string|null, revokedAt: string|null}
- $now : DateTimeImmutable
Return values
stringloadEntitiesForCacheTags()
Loads the entities being deleted only to find out their `additionalCacheTags()`. Fail-soft: what cannot be loaded is simply missing and the bump falls back to the class; it must never stop the delete.
private
loadEntitiesForCacheTags(int|array<string|int, mixed> $id) : array<int, object>
Parameters
- $id : int|array<string|int, mixed>
Return values
array<int, object>normalizeKeyValues()
Normalizes the key label and expiry input. Label: optional, at most `KEY_LABEL_MAX_LENGTH` characters. Expiry: `Y-m-d\TH:i` (also with seconds, or a space instead of `T`), in the application time zone, must be in the future; empty = never expires. Errors are `VALIDATION_FAILED` with `data.field` `keyLabel` / `keyExpiresAt`.
private
static normalizeKeyValues(mixed $label, mixed $expiresAt, DateTimeImmutable $now) : DateTimeImmutable|null}|Result
Parameters
- $label : mixed
- $expiresAt : mixed
- $now : DateTimeImmutable
Return values
DateTimeImmutable|null}|ResultnormalizeRoleIds()
private
normalizeRoleIds(mixed $roleIds) : array<int, int>|null
Parameters
- $roleIds : mixed
Return values
array<int, int>|null —null = invalid input or unknown role
normalizeValues()
private
normalizeValues(array<string, mixed> $values) : array{values: array{name: string, notes: string|null, limitPerSecond: int|null, limitPerMinute: int|null, userLimitPerMinute: int|null, ipLimitPerMinute: int|null}, roleIds: list|null}|Result
Parameters
- $values : array<string, mixed>
Return values
array{values: array{name: string, notes: string|null, limitPerSecond: int|null, limitPerMinute: int|null, userLimitPerMinute: int|null, ipLimitPerMinute: int|null}, roleIds: listparseExpiresAt()
Strict parser: exact format, no silent normalization of `2026-02-30` to `2026-03-02`.
private
static parseExpiresAt(string $value) : DateTimeImmutable|null
Parameters
- $value : string
Return values
DateTimeImmutable|nullrollbackBatch()
private
rollbackBatch() : void
saveWithHooks()
Runs the save itself: transaction, `beforeSave` / `afterSave` / `completedSave`, tree, cache.
private
saveWithHooks(TEntity $entity, array<string, mixed> $meta, array<int, string> $skipFields) : Result
Parameters
- $entity : TEntity
- $meta : array<string, mixed>
- $skipFields : array<int, string>
Return values
ResulttooManyKeys()
private
static tooManyKeys() : Result
Return values
ResultusesAssetPathTrait()
private
static usesAssetPathTrait(string $class) : bool
Parameters
- $class : string
Return values
boolwithRequiredRoles()
Returns the allowed roles plus the required guest role (`implicit = anonymous`).
private
withRequiredRoles(array<int, int> $roleIds) : array<int, int>
IMPORTANT: a client without the guest role gets 403 on everything without a token, including
#[PublicAction] (login is evaluated against the guest), so the application could not even log
in. Such a configuration is a trap, not a choice, so the manager refuses to store it.
Parameters
- $roleIds : array<int, int>