Skip to content

Extension points

tilttek/kudos

The package is at 0.x: its extension points are stable only from its 1.0 release. Until then, a minor version may change them, and its CHANGELOG says how.

PointWhat an application givesDefault
MessagesIts list of messagesMessages::defaults()
LimitsIts daily cap, and its limit per receiver over a periodFive a day, three per receiver in seven days
Contract\KudosPreferencesThe members' choice to take thanks or notPreferences\AcceptAll
Contract\MemberTimeZonesThe time zone each member's day is counted inTimeZone\SiteTimeZone, UTC
Contract\KudosObserverWhat to do with thanks given or cancelledNone

The messages and limits are values. The library keeps no state between two calls; the implementations an application gives keep none either.

Messages

The default list holds six messages, each with a name, a translation key and an English text:

NameTranslation keyText
helpkudos.message.helpThanks for your help
well_playedkudos.message.well_playedWell played
great_ideakudos.message.great_ideaGreat idea
welcomekudos.message.welcomeWelcome to the table
good_gamekudos.message.good_gameGood game
great_sessionkudos.message.great_sessionGreat session

An application adds its own, replaces a text, or takes some out:

$messages = Messages::defaults()
    ->with(new Message('nice_map', 'Nice map'))
    ->without('welcome');

A name is 1 to 64 lower-case letters, digits and _, starting with a letter; a text 1 to 200 bytes; a list at most 100 messages. The application translates each message with its translation key, and falls back on the text. Thanks keep the message's name: a message taken out of the list stays readable on the thanks given with it, and can no longer be given.

Preferences

KudosPreferences::accepts($receiver, $giver) says whether the receiver takes thanks from this giver. An application keeps the members' choice — a setting to decline all thanks, a list of members they decline them from — and answers from it. Preferences\AcceptAll takes every thanks.

Time zones

MemberTimeZones::of($member) gives the time zone the member's day is counted in: the one they chose, the site's otherwise. TimeZone\SiteTimeZone gives the site's zone to every member.

Observers

KudosObserver::given() and cancelled() are told once, after the journal wrote the entry, never for a request repeated under the same key. An observer that sends a notification or a message on a bus carries the event's identifiers, never more.

The badge criterion

The thanks a member gave are the activities of the verb kudos.given (Kudos::VERB) whose member they are, withdrawn ones left out. A badge of tilttek/badges reads them with a count on that verb:

use Tilttek\Badges\Criterion\Count;
use Tilttek\Badges\Criterion\Scope;

new Count(new Scope([Kudos::VERB]), 25); // have thanked other members 25 times

Outside tilttek/badges, Kudos::givenCount() and the journal's totals() give the same count. Thanks received are no measure: the library gives no way to count them, so no badge rewards popularity.