aRepository
MMO\core\classes · 1 symbol · generated 30 Sep 2026
aRepository
aRepository.php:22Collections container.
- Namespace
MMO\core\classes- Implements
- iRepository, ArrayAccess, IteratorAggregate
Index
| collections | ||
| addCollection($name, $collection) | Add collection | |
| createCollection($name, $entityClass, $collectionId) | Create and register a plain Collection for entities of $entityClass. | |
| createEntity($class, $data, $collection) | Create an entity from data using its array properties | |
| createLog($type, $origin, $collection, $data, $filters, $sorts, $limit, $offset) | Build (but not dispatch) a LogQuery entity describing a data-mutating operation, stored in the repository's LogQuery collection (if one is registered). | |
| debugName() | ||
| forceCommit($origin, $entities) | ||
| getCollection($name) | ||
| getCollectionByClass($entityClass, $allowChildClass) | Find the collection whose entities are (an exact match, or optionally a subclass of) $entityClass. | |
| getCollectionName($collection) | ||
| getCollections() | ||
| getDistinct($collection, $key) | Every value one property takes across a collection, once each, in ascending order. | |
| getEntities() | ||
| getIterator() | \IteratorAggregate::getIterator -- iterates name => iCollection | |
| hasCollection($collection) | ||
| hideLogData($collection, $data) | What a repository logs is what it wrote (mmo.pdo's row, mmo.mongodb's document or its changes), hidden properties (ArrayProperty::isHidden) included, and a log is exported… | |
| logDelete($origin, $collection, $data, $filters, $sorts, $limit, $offset) | Log and dispatch a DELETE operation. | |
| logInsert($origin, $collection, $data, $filters, $sorts, $limit, $offset) | Log and dispatch an INSERT operation. | |
| logStatus($origin, $collection, $data, $filters, $sorts, $limit, $offset) | Log and dispatch a STATUS-change operation. | |
| logUpdate($origin, $collection, $data, $filters, $sorts, $limit, $offset) | Log and dispatch an UPDATE operation. | |
| offsetExists($key) | \ArrayAccess::offsetExists | |
| offsetGet($key) | \ArrayAccess::offsetGet | |
| offsetSet($key, $value) | \ArrayAccess::offsetSet -- equivalent to addCollection | |
| offsetUnset($key) | \ArrayAccess::offsetUnset | |
| onCommit($commit) abstract | Persist a batch of entity changes. | |
| onFetch($event) | Listener for Fetch: resolves a repository-uid/collection-id#id (or repository-uid/collection-id#id/nested/path for an embedded value) URL, what Ent… | |
| searchText($query, $text) | Full-text search. Not implemented at this level -- a concrete repository backed by a search-capable store should override this. | |
| setCollections($cols) | Register a batch of collections at once, e.g. | |
| __construct($collections) | ||
| __wakeup() | Register this repository's onCommit / onFetch as listeners on the global |
Properties1
collections
- Type
- array
Methods29
addCollection($name, $collection)
aRepository.php:158Add collection
| $name | string | the collection's name |
| $collection | iCollection | |
| returns | iCollection |
createCollection($name, $entityClass, $collectionId)
aRepository.php:220Create and register a plain Collection for entities of $entityClass.
| $name | string | |
| $entityClass | string | |
| $collectionId = null | null | string | the collection's own id (defaults to $name) |
| returns | iCollection |
createEntity($class, $data, $collection)
aRepository.php:379Create an entity from data using its array properties
| $class | string | |
| $data = [] | array | |
| $collection = null | null | iCollection | |
| returns | iEntity | |
| throws | if $collection is null and no registered collection matches $class | |
| throws | if $collection is given but doesn't belong to this repository |
createLog($type, $origin, $collection, $data, $filters, $sorts, $limit, $offset)
aRepository.php:278Build (but not dispatch) a LogQuery entity describing a data-mutating operation, stored in the repository's LogQuery collection (if one is registered). logUpdate / logInsert / logDelete /
- See
logStatusare thin wrappers around this that also dispatch it.
| $type | cLogQuery | the kind of operation |
| $origin | object | string | who/what performed the operation |
| $collection | iCollection | string | the affected collection (or its name) |
| $data | array | the data written: a hidden property's value is logged as LogQuery::HIDDEN (hideLogData) |
| $filters = [] | Entity | array | the filter/entity that scoped the operation |
| $sorts = '' | string | |
| $limit = null | null | int | |
| $offset = null | null | int | |
| returns | LogQuery | |
| throws | if no LogQuery collection is registered on this repository |
debugName()
aRepository.php:56| returns | string | e.g. 'MMO\core\entities\Repository:[MEMORY REPOSITORY]' |
forceCommit($origin, $entities)
aRepository.php:70getCollection($name)
aRepository.php:168| $name | string | |
| returns | iCollection | |
| throws | if no collection is registered under $name |
getCollectionByClass($entityClass, $allowChildClass)
aRepository.php:185Find the collection whose entities are (an exact match, or optionally a subclass of) $entityClass.
| $entityClass | string | |
| $allowChildClass = true | bool | if true (the default), also match a collection whose entity class is an ancestor of $entityClass (an exact match is always preferred) |
| returns | null | iCollection | null if no collection matches |
getCollectionName($collection)
aRepository.php:149| $collection | iCollection | |
| returns | null | string | the name $collection is registered under, or null if it isn't one of this repository's collections |
getCollections()
aRepository.php:144| returns | array | every registered collection, keyed by name |
getDistinct($collection, $key)
aRepository.php:100Every value one property takes across a collection, once each, in ascending order.
| $collection | string | the collection's name |
| $key | string | the property (a /-separated path for a nested one) |
| returns | array |
getEntities()
aRepository.php:362| returns | array | every entity across every collection in this repository |
getIterator()
aRepository.php:225\IteratorAggregate::getIterator -- iterates name => iCollection
| returns | Traversable |
hasCollection($collection)
aRepository.php:208| $collection | iCollection | string | a name (checked by key) or an instance (checked by identity) |
| returns | bool |
hideLogData($collection, $data)
aRepository.php:307What a repository logs is what it wrote (mmo.pdo's row, mmo.mongodb's document or its changes), hidden properties (ArrayProperty::isHidden) included, and a log is exported like any entity: its data, a plain array, would tell what the entity itself never does -- a password's hash. Their values are replaced, not dropped: the log still tells they were written.
| $collection | iCollection | string | the collection written to, or its name |
| $data | array | property => value |
| returns | array | $data, every hidden property's value replaced with LogQuery::HIDDEN. A collection this repository does not have is logged as it is: nothing tells what it hides, and failing would fail the commit that logs it. |
logDelete($origin, $collection, $data, $filters, $sorts, $limit, $offset)
aRepository.php:341Log and dispatch a DELETE operation. See createLog for the parameters.
logInsert($origin, $collection, $data, $filters, $sorts, $limit, $offset)
aRepository.php:331Log and dispatch an INSERT operation. See createLog for the parameters.
logStatus($origin, $collection, $data, $filters, $sorts, $limit, $offset)
aRepository.php:351Log and dispatch a STATUS-change operation. See createLog for the parameters.
logUpdate($origin, $collection, $data, $filters, $sorts, $limit, $offset)
aRepository.php:321Log and dispatch an UPDATE operation. See createLog for the parameters.
offsetExists($key)
aRepository.php:257\ArrayAccess::offsetExists
offsetGet($key)
aRepository.php:241\ArrayAccess::offsetGet
| $key | mixed | |
| returns | iCollection |
offsetSet($key, $value)
aRepository.php:249\ArrayAccess::offsetSet -- equivalent to addCollection
offsetUnset($key)
aRepository.php:233\ArrayAccess::offsetUnset
onCommit($commit)
abstractaRepository.php:33Persist a batch of entity changes. Called automatically for every Commit dispatched with \MMO\commit(), but only for entities belonging to one of this repository's collections.
onFetch($event)
aRepository.php:400Listener for Fetch: resolves a repository-uid/collection-id#id (or repository-uid/collection-id#id/nested/path for an embedded value) URL, what Entity::uid gives, into the matching entity (or nested value), if it belongs to one of this repository's collections and no earlier listener already answered the fetch.
searchText($query, $text)
aRepository.php:85Full-text search. Not implemented at this level -- a concrete repository backed by a search-capable store should override this.
| $query | iCollection | Query | string | |
| $text | string | |
| returns | array | |
| throws | always, unless overridden |
setCollections($cols)
aRepository.php:123Register a batch of collections at once, e.g. from the repository's own configuration.
__construct($collections)
aRepository.php:38| $collections = [] | array | name => iCollection|entity-class-name, see setCollections |
__wakeup()
aRepository.php:49Register this repository's onCommit / onFetch as listeners on the global
- See
Commit/Fetchevents. Called automatically by the constructor, and again whenever the repository is unserialized (rebuilt from the sharedConfiguration).
| returns | void |
Inherited members (3)
| Methods | Declared by | Description | |
|---|---|---|---|
dropCollection($collection) | iRepository | ||
executeQuery($query) | iRepository | ||
uid() | iIdentifiable | Get the unique identifier |