Skip to content

Events

tilttek/luck-tokens-bundle

LuckTokens dispatches its events to the application's event dispatcher, once their entries are written, never for an operation sent again:

EventWhen
Tilttek\LuckTokens\Event\TokensGrantedTokens granted
Tilttek\LuckTokens\Event\TokensSpentTokens spent
Tilttek\LuckTokens\Event\TokensTransferredTokens passed from one holder to another
Tilttek\LuckTokens\Event\SessionStartedA session started, with its refreshes
Tilttek\LuckTokens\Event\HolderErasedA member erased under a pseudonym; it names neither the member nor a table
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Tilttek\LuckTokens\Event\TokensSpent;

#[AsEventListener]
final readonly class OfferTheReroll
{
    public function __invoke(TokensSpent $spent): void
    {
        // $spent->entry->table, ->holder, ->kind, ->reason, ->operation, ->position
    }
}

A listener runs inside the request that wrote the entries. Work that takes time — a notification, a push to the table's screen — goes through Messenger with the table, the operation and the position only: the handler reads the entry back from the ledger, so that a message carries no personal data.