Skip to content

Configuration

tilttek/luck-tokens-bundle
# config/packages/tilttek_luck_tokens.yaml
tilttek_luck_tokens:
    store: doctrine               # or memory, for tests
    connection: default           # the DBAL connection of the ledgers and of the rules kept there
    rules: configuration          # or doctrine, or service
    rules_service: ~              # with rules: service
    tables:
        'table:12':
            game_masters: ['member:7']
            kinds:
                - { key: inspiration, name: Inspiration, cap: 1, transferable: true }
                - { key: bennies, name: Bennies, cap: 5, scope: player, refresh: each-session, refresh_to: 3,
                    carry_over: 0, grants: anyone, transferable: true }
    clock: clock                  # the service of a Psr\Clock\ClockInterface
    max_entries: 100000           # the most entries the ledger of a table takes
    holder_access: self           # or security, or service
    holder_access_service: ~      # with holder_access: service
    lock:
        enabled: false
        factory: lock.factory     # the service of a Symfony\Component\Lock\LockFactory
        scope: holder             # or table
        ttl: 30.0                 # seconds, should the process die holding a lock
    privacy:
        member_kind: member       # a data subject 44 is the member member:44
KeyDefaultWhat it does
storedoctrineWhere the ledgers are kept: doctrine — DbalTokenLedger — or memory — the library's InMemoryTokenLedger, for tests and scripts.
connectiondefaultThe DBAL connection, doctrine.dbal.<name>_connection.
rulesconfigurationconfiguration: the tables below, read once by ConfiguredTokenRules. doctrine: DbalTokenRules, which the application fills from the settings of each table; it needs the doctrine store. service: the service named by rules_service.
rules_servicenullThe id of a service implementing Tilttek\LuckTokens\Contract\TokenRules; required with rules: service.
tablesnoneThe rules of each table, by its reference: its game masters and its kinds, as TableRules::fromArray() reads them. Only with rules: configuration.
clockclockThe clock of the entries; FrameworkBundle registers clock.
max_entries100 000The size of a ledger, 1 or more.
holder_accessselfself: each holder spends and passes their own tokens. security: the security voters decide, see Who controls whom. service: the service named by holder_access_service. The game masters of a table always may.
holder_access_servicenullThe id of a service implementing Tilttek\LuckTokens\Contract\HolderAccess; required with holder_access: service.
lock.enabledfalseRegisters LockedLuckTokens, see Locks.
lock.factorylock.factoryThe lock factory; FrameworkBundle registers lock.factory once framework.lock is set.
lock.scopeholderholder or table.
lock.ttl30.0How long a lock lives at most, 1 second or more.
privacy.member_kindmemberThe kind of the reference a data subject of phil/privacy-bundle stands for.

A kind of token takes key, name and cap, and optionally scope (character or player), refresh (never or each-session), refresh_to, carry_over, grants (game-masters or anyone) and transferable; a key left out takes the library's default.

Checked when the container is compiled

The container refuses, rather than the first operation:

  • tables that are not rules the library takes — a kind without a cap, a refresh amount on a kind never refreshed, a reference that is none —, with InvalidTokenRule;
  • tables given while the rules come from elsewhere, rules in the database with the memory store, service without the id of the service, security without the Security component and the locks without the Lock component, with InvalidConfigurationException.