Skip to content

Events

tilttek/progression-bundle

The projection and the sweep tell the application's event dispatcher:

EventDispatched whenCarries
Tilttek\ProgressionBundle\Infrastructure\Event\LevelUpA subject reaches a higher level of a trackchange: a LevelChange (track, subject, season, from, to, moment, activity)
Tilttek\ProgressionBundle\Infrastructure\Event\LevelDownA cancellation takes a subject back to a lower levelchange
Tilttek\Progression\ReachedMilestoneA subject passes a milestone, once per seasontrack, milestone, subject, member, season, moment, activity
Tilttek\Progression\Streak\StreakBrokenA member's streak breaks, oncestreak, member, length, last active unit, moment

Rewarding a milestone

#[AsEventListener]
final readonly class RewardMilestones
{
    public function __construct(private Points $points) {}

    public function __invoke(ReachedMilestone $reached): void
    {
        $this->points->grant($reached->member, 100, 'milestone:'.$reached->track.':'.$reached->milestone.':'.$reached->subject->toString().':'.$reached->season);
    }
}

The key makes the grant written once even if the listener runs twice. During a rebuild only the levels above those held before are told, and neither a level lost nor a broken streak is; milestones are never told again.