ApiClient
MMO\oauth\entities · 1 symbole · générée le 30 Nov 2026
ApiClient
ApiClient.php:23A credential of an account for its own code (a client's integration): it calls the API as that account (its
- Espace de noms
MMO\oauth\entities- Étend
- Entity
- Implémente
- iClient, iGuarded
- Utilise les traits
- tWithScopes
- Voir
$owner, \MMO\oauth\account()), with only the rights it was given among the owner's -- never more: its scopes are those of its own the owner also holds, the owner's refusals kept (getScopes) -- and within the owner's perimeter, which the application reads on the account. Its secret is stored hashed, shown once at its making;POST oauth/token(client_credentials) exchanges it for a short access token. An archived client, an expired one, or one whose owner is archived gets none. An administrator makes it for an account (AccessController'srouteCreateApiClient), for a short time, renewed with a new secret (renew). Guarded by those routes (iGuarded): nodata.*scope is asked of who makes it, and the generic data api refuses it to whoever lacks them.
Index
| FLAG_EXPIRY_NOTICED | its owner was told it expires soon (AccessController::noticeExpiringApiClients): once, until renewed | |
| clientFlags | ||
| expires | When it stops being accepted | |
| lastUsed | When it last got a token | |
| owner | The account it acts for: its rights bound, its perimeter | |
| scopes | ||
| secret | The hash of its secret (verifySecret): never exported | |
| allow($uids) | Add scope if it is not already disallowed | |
| applyScopes($scopes, $set) | Apply this scopes onto a list of scopes | |
| blameScope($uid) | ||
| clearScopes() | ||
| Create($collection, $owner, $label, $scopes, $expires) static | Make a client of $owner in $collection, and its secret -- to show once: only its hash is kept. | |
| disallow($uids) | ||
| getClientRedirectUri() | None: a client of its owner's code gets its token directly (client_credentials), never redirected | |
| getClientSecret() | ||
| getExpires() | ||
| getOwner() | ||
| getOwnScopes() | ||
| getScope($uid) | ||
| getScopes() | Its rights: each rule it was given that its owner holds, and every refusal of the owner beneath one -- never more than the owner; nothing without one. | |
| getUniqueName() | ||
| getUsername() | ||
| hasClientFlag($flag) | ||
| hasScope($uid) | ||
| isAllowed($uids) | Test if all scopes are allowed | |
| isAnyAllowed($uids) | Test if any scope is allowed Scopes expressed as string can be a list of scope's uid seperated by a space (in this case, all scopes MUST be allowed). | |
| isConfidential() | ||
| isUsable() | ||
| renew($expires) | Give it a new secret and a new expiry -- the old secret ends now (its tokens are its maker's to end) -- and forget that its expiry was told. | |
| scopesText($separator, $true, $false) | ||
| setScope($uid, $value) | Set the scope's value | |
| setScopes($scopes) | ||
| setUsed() | Note that it got a token now | |
| updateClientFlag($flag, $value) | ||
| verifySecret($secret) |
Constantes1
FLAG_EXPIRY_NOTICED
its owner was told it expires soon (AccessController::noticeExpiringApiClients): once, until renewed
Propriétés6
clientFlags
- Type
- int
expires
When it stops being accepted
- Type
- null | DateTimeImmutable
lastUsed
When it last got a token
- Type
- null | DateTimeImmutable
owner
The account it acts for: its rights bound, its perimeter
scopes
- Type
- array
secret
The hash of its secret (verifySecret): never exported
Méthodes28
allow($uids)
tWithScopes.php:100Add scope if it is not already disallowed
applyScopes($scopes, $set)
tWithScopes.php:138Apply this scopes onto a list of scopes
| $scopes | array | list of {scope:uid} => {allow:bool} |
| $set = false | bool | mergeScopes |
| retourne | void |
blameScope($uid)
ApiClient.php:185clearScopes()
tWithScopes.php:91| retourne | void |
Create($collection, $owner, $label, $scopes, $expires)
staticApiClient.php:69Make a client of $owner in $collection, and its secret -- to show once: only its hash is kept.
| $collection | iCollection | where the API clients are kept |
| $owner | iUser | |
| $label | string | |
| $scopes | array | |
| $expires | null | DateTimeImmutable | |
| retourne | array | static, 1: string} the client (not saved yet: \MMO\commit()) and its secret |
disallow($uids)
tWithScopes.php:106getClientRedirectUri()
ApiClient.php:169None: a client of its owner's code gets its token directly (client_credentials), never redirected
| retourne | string |
getClientSecret()
ApiClient.php:156getExpires()
ApiClient.php:104| retourne | null | DateTimeImmutable |
getOwner()
ApiClient.php:95getOwnScopes()
ApiClient.php:124getScope($uid)
tWithScopes.php:27getScopes()
ApiClient.php:135Its rights: each rule it was given that its owner holds, and every refusal of the owner beneath one -- never more than the owner; nothing without one.
| retourne | array | bool> |
getUniqueName()
ApiClient.php:152| retourne | string |
getUsername()
ApiClient.php:100| retourne | string | who it is, for a log or a page: its owner's name and its label |
hasClientFlag($flag)
ApiClient.php:173hasScope($uid)
tWithScopes.php:31isAllowed($uids)
tWithScopes.php:117Test if all scopes are allowed
isAnyAllowed($uids)
tWithScopes.php:127Test if any scope is allowed Scopes expressed as string can be a list of scope's uid seperated by a space (in this case, all scopes MUST be allowed).
isConfidential()
ApiClient.php:164| retourne | bool |
isUsable()
ApiClient.php:117| retourne | bool | whether it may get a token: active, not expired, its owner active |
renew($expires)
ApiClient.php:85Give it a new secret and a new expiry -- the old secret ends now (its tokens are its maker's to end) -- and forget that its expiry was told.
| $expires | DateTimeImmutable | |
| retourne | string | the new secret, to show once |
scopesText($separator, $true, $false)
tWithScopes.php:44setScope($uid, $value)
tWithScopes.php:65Set the scope's value
setScopes($scopes)
tWithScopes.php:76setUsed()
ApiClient.php:109Note that it got a token now
| retourne | void |
updateClientFlag($flag, $value)
ApiClient.php:177verifySecret($secret)
ApiClient.php:160Membres hérités (118)
| Constantes | Déclaré par | Description | |
|---|---|---|---|
FLAG_CHANGED | iEntity | ||
FLAG_CREATED | iEntity | ||
FLAG_FIRST_CONNECTION | iClient | ||
FLAG_IGNORE_CHANGE | iEntity | ||
FLAG_IGNORE_ENTITY | iEntity | ||
FLAG_OPACIFY | iEntity | ||
FLAG_REMOVED | iEntity | ||
FLAG_RESET_SECRET | iClient | ||
FLAG_USER_DEFINED | iClient |
| Propriétés | Déclaré par | Description | |
|---|---|---|---|
ArrayProperties | aEntity | ||
changes | aEntity | ||
collection | Entity | ||
ctime | Entity | ||
errors | aEntity | ||
flags | aEntity | ||
id | Entity | identifier in collection | |
label | Entity | short name | |
links | aEntity | ||
mtime | Entity | ||
refusals | aEntity | ||
SearchProperties | aEntity | ||
status | aEntity | ||
title | Entity | long name |
| Méthodes | Déclaré par | Description | |
|---|---|---|---|
addFlags($flags) | aEntity | ||
addLink($link) | aEntity | Append a link. | |
archive() | aEntity | This function is called to 'delete' the entity. | |
ArrayProperties() | aEntity | Build (once per class, then cached in the static $ArrayProperties array) the list of every #[ArrayProperty] declared on this class, its parent classes, and the traits they use -- by reflection… | |
ArrayProperty($name) | aEntity | ||
CheckData($data, $errors) | aEntity | Check data before it touches any entity: would an entity made from $data be valid? | |
clearChanges() | aEntity | Reset change tracking: clears iEntity::FLAG_CHANGED and forgets every recorded change. | |
compareTo($value) | aEntity | Compare value | |
conversionError($key, $e) | aEntity | The error recorded for a value that could not be set at all (usually: it could not be converted to its property's type), in the same form as a validation error. | |
Copy($entity, $properties) | Entity | Build a new entity from $entity's own stored data (a duplicate, minus its id -- so saving it creates a genuinely new record -- in the same collection). | |
debugName() | aEntity | ||
get($path, $default) | aEntity | Read a (possibly nested) value by json-path, e.g. | |
getArrayProperty($key, $isRef, $store) | aEntity | Read a single array property's current value, through its getter (a direct property, a path alias, or a method). | |
getChanges($asArray, $store) | aEntity | ||
getCollection() | Entity | ||
getCtime() | Entity | ||
getErrors() | aEntity | ||
getFlags() | aEntity | ||
getId() | Entity | ||
getInvalidItems($keys) | aEntity | The items of the values set that could not be converted: a list or an object was given, one of its items was not valid (an unknown uid), so the property kept its previous value. | |
getLabel() | Entity | ||
getLinks() | aEntity | ||
getLinksByRel($rels, $all) | aEntity | Get a list of Reference that have a specific relationship. | |
getMetadata() | aEntity | ||
getMtime() | Entity | ||
getRefusals($keys, $seen) | aEntity | The values a setter refused: the property's own method (setImage()) threw one of the framework's exceptions, not a value it could not convert -- the entity kept its previous value and said why in… | |
getRepository() | Entity | ||
getStatus() | aEntity | ||
getTitle() | Entity | ||
getView() | aEntity | ||
hasChanged($keys) | aEntity | ||
hasFlags($flags, $strict) | aEntity | ||
hasStatusChanged() | aEntity | ||
HiddenPath($path) | aEntity | The hidden property (ArrayProperty::isHidden) a json-path goes through, known from the declared types alone: of this class, or of a class a property on the way may hold -- every class of its t… | |
ignore() | Entity | Ignore everything about this entity: discard its pending changes and flag it so it's skipped by future commits (aRepository::onCommit). | |
ignoreChanges($value) | aEntity | Temporarily suppress markChanged (used e.g. | |
isActive() | aEntity | ||
isArchive() | aEntity | ||
isArrayPropertySet($key, $store) | Entity | Same as aEntity::isArrayPropertySet, but 'ctime'/'mtime' are never reported as "set" (they're always present, so listing them adds no information), and neither is 'id' once the entity is alrea… | |
isChanged() | aEntity | ||
isCreated() | aEntity | ||
isDraft() | aEntity | ||
isEmpty() | aEntity | ||
isFinal() | aEntity | ||
isHiddenPath($path) | aEntity | ||
isIgnored() | Entity | ||
isOpacified() | aEntity | ||
isPending() | aEntity | ||
isRemoved() | aEntity | ||
isSimilar($value) | Entity | ||
isUnique() | aEntity | Tells if an entity has enough information to be unique (at least one unique group has no empty value) | |
isValid() | aEntity | ||
isValidated() | aEntity | ||
ListClassReferences($onlyStorable) | aEntity | Get a list of all the classes and their properties that are using references to this class. | |
loadArray($data, $coerceOptions, $fromStore) | Entity | Same as aEntity::loadArray, but 'ctime'/'mtime' are never taken from $data: they belong to the server (set when the entity is created, bumped by markChanged), and a client sending back th… | |
loadFromStore($data) | Entity | Restore from stored data, setting 'ctime'/'mtime' directly (bypassing their normal setters -- see setCtime/setMtime, which are read-only via #[ArrayProperty]). | |
localName() | Entity | ||
loopReferences() | Entity | Yield all the entities in the repository that have a reference on this one. | |
markChanged($keys) | Entity | Same as aEntity::markChanged, also bumping $mtime to now -- unless the change itself was to 'ctime'/'mtime' (avoiding infinite recursion via setMtime's own markChanged call). | |
mutate($type, $path, $value, $oldValue) | aEntity | \MMO\core\interfaces\iMutationObserver::mutate -- besides the normal tArrayProperties::mutate behavior, walks up $path to find the nearest enclosing aEntity (the mutation may have happened dee… | |
offsetExists($key) | aEntity | \ArrayAccess::offsetExists -- tells whether $key is a *declared* #[ArrayProperty], not whether it currently holds a non-default value (use isArrayPropertySet for that). | |
offsetGet($key) | aEntity | \ArrayAccess::offsetGet | |
offsetSet($key, $value) | aEntity | \ArrayAccess::offsetSet | |
offsetUnset($key) | aEntity | \ArrayAccess::offsetUnset -- equivalent to setting the property to null (its coerced value depends on the property's schema: e.g. | |
opacify($value) | aEntity | Hide this entity's properties from toArray output (typically used to redact an entity the current viewer isn't allowed to see the details of, while still letting it be referenced by uid/metadata). | |
push($path, $value) | aEntity | Append a value to a (possibly nested) list property by json-path. | |
reload() | Entity | Reload entity from its repository | |
removeFlags($flags) | aEntity | ||
removeLink($link) | aEntity | Remove a link (by identity). | |
removePermanently($force) | Entity | Remove entity from database | |
replaceBy($replace, $mergeData) | Entity | Replace this entity by another one, trying to change all references to this entity to the new one. | |
Schema() | aEntity | The JSON-Schema describing every #[ArrayProperty] of this class (built once and cached by ArrayProperties). | |
SearchProperty($name) | aEntity | ||
set($path, $value) | aEntity | Write a (possibly nested) value by json-path, creating intermediate structure as needed. | |
setArrayProperty($key, $value, $coerceOptions, $ignoreReadonly) | aEntity | Same as tArrayProperties::setArrayProperty, plus: any coercion/validation failure is caught and recorded in getErrors (making the entity isValid()-false) instead of propagating as an… | |
setArrayPropertyOffset($key, $offset, $value, $coerceOptions) | aEntity | Same as tArrayProperties::setArrayPropertyOffset, plus: when pushing (offset === null) a new entity onto a list property, if an existing item is isSimilar to the new value, that item's of… | |
setCollection($collection, $removeFromCollection) | Entity | Move this entity to (or out of, if null) a collection. | |
setCtime($date, $force) | Entity | Set creation time | |
setId($id) | Entity | Set the id, re-registering this entity in its $collection under the new id (Collection's entities are keyed by id). | |
setLinks($links) | aEntity | Replace every link with $links. | |
setMtime($date, $force) | Entity | Set modification time | |
setStatus($status) | aEntity | ||
store() | aEntity | Export all array properties with store set to true. | |
test($filter) | aEntity | ||
toArray($fields, $flatten, $recursive) | aEntity | Same as tArrayProperties::toArray, except an isOpacified entity always exports only its 'uid' and 'metadata' (its other properties are hidden from output). | |
toLink($attributes) | aEntity | ||
traitMutate($type, $path, $value, $oldValue) | aEntity | \MMO\core\interfaces\iMutationObserver::mutate -- reacts to a mutation that happened deep inside one of this object's array properties (e.g. | |
traitSetArrayProperty($key, $value, $coerceOptions, $fromStore) | aEntity | Set array property | |
traitSetArrayPropertyOffset($key, $offset, $value, $coerceOptions) | aEntity | Set/push a value into an array property | |
traitToArray($fields, $flatten, $recursive) | aEntity | Export fields to an array. | |
uid() | Entity | ||
validate($errors) | aEntity | Validate this entity: its current values against its own tArrayProperties::Schema, plus every value that could not even be set -- one that could not be converted to its property's type never r… | |
View() | aEntity | ||
warnRemovedField($key) | aEntity | A stored record holds $key, which its class no longer declares (a field removed since it was saved): a warning, once per class and field in a process. | |
__construct($data, $collection) | Entity |