aRepository
MMO\core\classes · 1 symbol · generated 27 Oct 2026
aRepository
aRepository.php:23Collections 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 (?search[type]=$text of RepositoryController::routeGet), on top of the query's own filters, its sort and its page. | |
| 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:185Add collection
| $name | string | the collection's name |
| $collection | iCollection | |
| returns | iCollection |
createCollection($name, $entityClass, $collectionId)
aRepository.php:247Create 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:406Create 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:305Build (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:57| returns | string | e.g. 'MMO\core\entities\Repository:[MEMORY REPOSITORY]' |
forceCommit($origin, $entities)
aRepository.php:71getCollection($name)
aRepository.php:195| $name | string | |
| returns | iCollection | |
| throws | if no collection is registered under $name |
getCollectionByClass($entityClass, $allowChildClass)
aRepository.php:212Find 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:176| $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:171| returns | array | every registered collection, keyed by name |
getDistinct($collection, $key)
aRepository.php:127Every 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:389| returns | array | every entity across every collection in this repository |
getIterator()
aRepository.php:252\IteratorAggregate::getIterator -- iterates name => iCollection
| returns | Traversable |
hasCollection($collection)
aRepository.php:235| $collection | iCollection | string | a name (checked by key) or an instance (checked by identity) |
| returns | bool |
hideLogData($collection, $data)
aRepository.php:334What 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:368Log and dispatch a DELETE operation. See createLog for the parameters.
logInsert($origin, $collection, $data, $filters, $sorts, $limit, $offset)
aRepository.php:358Log and dispatch an INSERT operation. See createLog for the parameters.
logStatus($origin, $collection, $data, $filters, $sorts, $limit, $offset)
aRepository.php:378Log and dispatch a STATUS-change operation. See createLog for the parameters.
logUpdate($origin, $collection, $data, $filters, $sorts, $limit, $offset)
aRepository.php:348Log and dispatch an UPDATE operation. See createLog for the parameters.
offsetExists($key)
aRepository.php:284\ArrayAccess::offsetExists
offsetGet($key)
aRepository.php:268\ArrayAccess::offsetGet
| $key | mixed | |
| returns | iCollection |
offsetSet($key, $value)
aRepository.php:276\ArrayAccess::offsetSet -- equivalent to addCollection
offsetUnset($key)
aRepository.php:260\ArrayAccess::offsetUnset
onCommit($commit)
abstractaRepository.php:34Persist 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:427Listener 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:92Full-text search (?search[type]=$text of RepositoryController::routeGet), on top of the query's own filters, its sort and its page.
- See
FilterOperator::testmakes of a text), which mmo.pdo turns into SQL. A repository with a search-capable store overrides it (MongoRepository::searchText). NOTE: until 2026-10 it threw « not implemented ».
| $query | iCollection | Query | string | the query (its filters narrow the result), or the collection to search |
| $text | string | the words to find |
| returns | array |
setCollections($cols)
aRepository.php:150Register a batch of collections at once, e.g. from the repository's own configuration.
__construct($collections)
aRepository.php:39| $collections = [] | array | name => iCollection|entity-class-name, see setCollections |
__wakeup()
aRepository.php:50Register 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 |