Index

Repository

MMO\core\entities · 1 symbol · generated 5 Oct 2026

class

Repository

Repository.php:20

Collections container.

class MMO\core\entities\Repository extends MMO\core\classes\aRepository
Namespace
MMO\core\entities
Extends
aRepository
A collection registers itself for commit when it is built ([`Collection::__construct`](https://mcp.mmoframework.fr/documentation/mmo.core/php/entities/Collection.md#collection--construct)), so a change is saved by `commit()` with nothing to register by hand. [`Collection::registerCommit`](https://mcp.mmoframework.fr/documentation/mmo.core/php/entities/Collection.md#collection-registercommit) turns that off. A minimal, purely in-memory repository: entities live only in their [`Collection`](https://mcp.mmoframework.fr/documentation/mmo.core/php/entities/Collection.md#collection) (no external backing store), so [`executeQuery`](https://mcp.mmoframework.fr/documentation/mmo.core/php/entities/Repository.md#repository-executequery) just delegates to the collection's own local filtering, ids are locally generated ([`generateId`](https://mcp.mmoframework.fr/documentation/mmo.core/php/entities/Repository.md#repository-generateid)), and [`onCommit`](https://mcp.mmoframework.fr/documentation/mmo.core/php/entities/Repository.md#repository-oncommit) has nothing to actually persist.
$repo = new Repository(); $repo->addCollection('users', new Collection(User::class, $repo, 'users'));

Index

createEntity($class, $data, $collection)Same as aRepository::createEntity, auto-assigning the next id (generateId) if $data has none.
dropCollection($collection)NOTE: this used to just return $this->hasCollection($collection); -- reporting whether the collection exists, but never actually removing it from aRepository::$collections.
executeQuery($query, $opts)Find entities by content (delegates to the collection's own in-memory filtering -- see Collection::executeQuery).
generateId($collection)
onCommit($commit)There's nothing to actually persist here (entities already live in-memory in their collection) -- just logs a notice for each changed entity this repository is responsible for.
uid()

Methods6

dropCollection($collection)

Repository.php:34

NOTE: this used to just return $this->hasCollection($collection); -- reporting whether the collection exists, but never actually removing it from aRepository::$collections. Verified concretely:

function dropCollection(MMO\core\interfaces\iCollection|string $collection): bool
See
Collection::drop() (which calls this to do the actual removal) reported success, yet the collection remained fully registered and reachable via aRepository::getCollection afterward. Fixed to actually remove it (aRepository has no existing removal method to delegate to).
$collectioniCollection | string
returnsboolfalse if $collection wasn't registered.

generateId($collection)

Repository.php:55
function generateId(MMO\core\interfaces\iCollection $collection): int
$collectioniCollection
returnsintone more than the highest existing (loaded) entity id, numerically -- or 1 if the collection is empty.

onCommit($commit)

Repository.php:80

There's nothing to actually persist here (entities already live in-memory in their collection) -- just logs a notice for each changed entity this repository is responsible for.

function onCommit(MMO\core\events\Commit $commit): void
$commitCommit
returnsvoid
Inherited members (28)
PropertiesDeclared byDescription
collectionsaRepository
MethodsDeclared byDescription
addCollection($name, $collection)aRepositoryAdd collection
createCollection($name, $entityClass, $collectionId)aRepositoryCreate and register a plain Collection for entities of $entityClass.
createLog($type, $origin, $collection, $data, $filters, $sorts, $limit, $offset)aRepositoryBuild (but not dispatch) a LogQuery entity describing a data-mutating operation, stored in the repository's LogQuery collection (if one is registered).
debugName()aRepository
forceCommit($origin, $entities)aRepository
getCollection($name)aRepository
getCollectionByClass($entityClass, $allowChildClass)aRepositoryFind the collection whose entities are (an exact match, or optionally a subclass of) $entityClass.
getCollectionName($collection)aRepository
getCollections()aRepository
getDistinct($collection, $key)aRepositoryEvery value one property takes across a collection, once each, in ascending order.
getEntities()aRepository
getIterator()aRepository\IteratorAggregate::getIterator -- iterates name => iCollection
hasCollection($collection)aRepository
hideLogData($collection, $data)aRepositoryWhat 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)aRepositoryLog and dispatch a DELETE operation.
logInsert($origin, $collection, $data, $filters, $sorts, $limit, $offset)aRepositoryLog and dispatch an INSERT operation.
logStatus($origin, $collection, $data, $filters, $sorts, $limit, $offset)aRepositoryLog and dispatch a STATUS-change operation.
logUpdate($origin, $collection, $data, $filters, $sorts, $limit, $offset)aRepositoryLog and dispatch an UPDATE operation.
offsetExists($key)aRepository\ArrayAccess::offsetExists
offsetGet($key)aRepository\ArrayAccess::offsetGet
offsetSet($key, $value)aRepository\ArrayAccess::offsetSet -- equivalent to addCollection
offsetUnset($key)aRepository\ArrayAccess::offsetUnset
onFetch($event)aRepositoryListener 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)aRepositoryFull-text search. Not implemented at this level -- a concrete repository backed by a search-capable store should override this.
setCollections($cols)aRepositoryRegister a batch of collections at once, e.g.
__construct($collections)aRepository
__wakeup()aRepositoryRegister this repository's onCommit / onFetch as listeners on the global