Entity
MMO\core\entities · 1 symbol · generated 5 Oct 2026
Entity
Entity.php:17The framework's standard, storable entity: an id, a label/title, and creation/modification timestamps on top of aEntity's schema/property/change-tracking machinery, plus the repository-facing bookkeeping (which Collection it belongs to, reference tracking for safe deletion) that a raw aEntity doesn't provide on its own.
- Namespace
MMO\core\entities- Extends
- aEntity
Index
| collection | ||
| ctime | ||
| id | identifier in collection | |
| label | short name | |
| mtime | ||
| title | long name | |
| Copy($entity, $properties) static | 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). | |
| getCollection() | ||
| getCtime() | ||
| getId() | ||
| getLabel() | ||
| getMtime() | ||
| getRepository() | ||
| getTitle() | ||
| ignore() | Ignore everything about this entity: discard its pending changes and flag it so it's skipped by future commits (aRepository::onCommit). | |
| isArrayPropertySet($key, $store) | 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… | |
| isIgnored() | ||
| isSimilar($value) | ||
| loadArray($data, $coerceOptions, $fromStore) | 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) | Restore from stored data, setting 'ctime'/'mtime' directly (bypassing their normal setters -- see setCtime/setMtime, which are read-only via #[ArrayProperty]). | |
| localName() | ||
| loopReferences() | Yield all the entities in the repository that have a reference on this one. | |
| markChanged($keys) | 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). | |
| reload() | Reload entity from its repository | |
| removePermanently($force) | Remove entity from database | |
| replaceBy($replace, $mergeData) | Replace this entity by another one, trying to change all references to this entity to the new one. | |
| setCollection($collection, $removeFromCollection) | Move this entity to (or out of, if null) a collection. | |
| setCtime($date, $force) | Set creation time | |
| setId($id) | Set the id, re-registering this entity in its $collection under the new id (Collection's entities are keyed by id). | |
| setMtime($date, $force) | Set modification time | |
| uid() | ||
| __construct($data, $collection) |
Properties6
collection
- Type
- null | iCollection
ctime
- Type
- DateTime
id
identifier in collection
- Type
- mixed
label
short name
mtime
- Type
- DateTime
title
long name
Methods26
Copy($entity, $properties)
staticEntity.php:103Build 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).
getCollection()
Entity.php:182| returns | null | iCollection | the collection this entity belongs to, if any. |
getCtime()
Entity.php:203| returns | DateTime | when this entity was created. |
getId()
Entity.php:143| returns | mixed | this entity's id, or null if it hasn't been assigned one yet (a new, unsaved entity). |
getLabel()
Entity.php:198| returns | string | the 'label' property, falling back to aEntity::getLabel. |
getMtime()
Entity.php:208| returns | DateTime | when this entity was last modified. |
getRepository()
Entity.php:187| returns | null | iRepository | the repository behind getCollection, if any. |
getTitle()
Entity.php:193| returns | string | the 'title' property, falling back to aEntity::getTitle (typically derived from the schema's own title template). |
ignore()
Entity.php:131Ignore everything about this entity: discard its pending changes and flag it so it's skipped by future commits (aRepository::onCommit).
| returns | void |
isArrayPropertySet($key, $store)
Entity.php:257Same 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 already created (it's immutable metadata by then, not meaningful "changed data").
isIgnored()
Entity.php:137isSimilar($value)
Entity.php:114| $value | aEntity | array | |
| returns | bool | same id, or (falling back to aEntity::isSimilar) the parent's own unique-property-based comparison. |
loadArray($data, $coerceOptions, $fromStore)
Entity.php:91Same 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 the values it read would otherwise keep the old modification time. A stored record restores them through loadFromStore.
loadFromStore($data)
Entity.php:76Restore from stored data, setting 'ctime'/'mtime' directly (bypassing their normal setters -- see setCtime/setMtime, which are read-only via #[ArrayProperty]).
localName()
Entity.php:162| returns | string | a human-friendlier reference: the collection's name, '/', and this entity's id. |
loopReferences()
Entity.php:294Yield all the entities in the repository that have a reference on this one.
- See
removePermanently's "don't delete a still-referenced entity" safety check, andreplaceBy) never actually found/updated any reference held in a list/object property. Fixed to check for membership (in_array($this, $value, true)) instead of identity for those properties.
| returns | Generator | key => entity |
markChanged($keys)
Entity.php:119Same 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).
reload()
Entity.php:339Reload entity from its repository
| returns | self |
removePermanently($force)
Entity.php:270Remove entity from database
replaceBy($replace, $mergeData)
Entity.php:324Replace this entity by another one, trying to change all references to this entity to the new one.
setCollection($collection, $removeFromCollection)
Entity.php:172Move this entity to (or out of, if null) a collection.
| $collection | null | iCollection | |
| $removeFromCollection = true | bool | if true (default), also remove it from its current collection first. |
| returns | bool | false if $collection is unchanged. |
setCtime($date, $force)
Entity.php:217Set creation time
| $date | DateTimeInterface | string | int | |
| $force = true | bool | if false only set time if it is anterior to the current set time (used for unserialization) |
| returns | bool |
setId($id)
Entity.php:148Set the id, re-registering this entity in its $collection under the new id (Collection's entities are keyed by id). @return bool false if $id is unchanged.
setMtime($date, $force)
Entity.php:239Set modification time
| $date | DateTimeInterface | string | int | |
| $force = true | bool | if false only set time if it is anterior to the current set time (used for unserialization) |
| returns | bool |
uid()
Entity.php:157| returns | string | a globally-unique reference: the collection's own uid, '#', and this entity's id. |
__construct($data, $collection)
Entity.php:61| $data = [] | array | initial property values (see aEntity::loadArray). 'ctime'/'mtime' default to 'now' if not given. |
| $collection = null | null | iCollection | added to it before $data is loaded, so cross-referencing children can find it. |
Inherited members (79)
| Constants | Declared by | Description | |
|---|---|---|---|
FLAG_CHANGED | iEntity | ||
FLAG_CREATED | iEntity | ||
FLAG_IGNORE_CHANGE | iEntity | ||
FLAG_IGNORE_ENTITY | iEntity | ||
FLAG_OPACIFY | iEntity | ||
FLAG_REMOVED | iEntity |
| Properties | Declared by | Description | |
|---|---|---|---|
ArrayProperties | aEntity | ||
changes | aEntity | ||
errors | aEntity | ||
flags | aEntity | ||
links | aEntity | ||
SearchProperties | aEntity | ||
status | aEntity |
| Methods | Declared by | 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. | |
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 | ||
getErrors() | aEntity | ||
getFlags() | aEntity | ||
getLinks() | aEntity | ||
getLinksByRel($rels, $all) | aEntity | Get a list of Reference that have a specific relationship. | |
getMetadata() | aEntity | ||
getStatus() | aEntity | ||
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… | |
ignoreChanges($value) | aEntity | Temporarily suppress markChanged (used e.g. | |
isActive() | aEntity | ||
isArchive() | aEntity | ||
isChanged() | aEntity | ||
isCreated() | aEntity | ||
isDraft() | aEntity | ||
isEmpty() | aEntity | ||
isFinal() | aEntity | ||
isHiddenPath($path) | aEntity | ||
isOpacified() | aEntity | ||
isPending() | aEntity | ||
isRemoved() | aEntity | ||
isUnique() | aEntity | Tells if an entity has enough information to be unique (at least one unique group has no null) | |
isValid() | aEntity | ||
isValidated() | aEntity | ||
ListClassReferences($onlyStorable) | aEntity | Get a list of all the classes and their properties that are using references to this class. | |
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. | |
removeFlags($flags) | aEntity | ||
removeLink($link) | aEntity | Remove a link (by identity). | |
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… | |
setLinks($links) | aEntity | Replace every link with $links. | |
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. | |
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 |