Skip to content

Writing a store

tilttek/quests

The library keeps nothing itself: four stores do, and an application implements them over its storage — or takes the in-memory ones for tests. tilttek/quests-bundle implements them on Doctrine DBAL.

ContractKeepsWhat matters
ContributionStoreWhat each activity brought to a stepWritten once per quest, step and activity — add() returns false the second time; read by quest, members and period by moment, then activity, then step; forget($since) before a rebuild
EnrolmentStoreAcceptances and abandonmentsOne per quest and member, replaced on save; read by quest, ordered by member, and by member, ordered by quest
CompletionStoreThe journal of accomplished questsWritten once per quest, occurrence and subject; latest() the subject's most recent; forget($since) returns what it forgot
DuelStoreDuels by keyReplaced on save; accepted() the accepted duels of a quest a member is a side of; due() the offers at or before a moment and the accepted duels ended by now; reopen($since) accepts again the duels won since

Each store erases a member.

The tests of the library define a contract test case per store — ContributionStoreTestCase, EnrolmentStoreTestCase, CompletionStoreTestCase, DuelStoreTestCase —: extend one with your store to check it behaves as the library expects.