Pre-1.0. Not intended for public use yet. The API is subject to undocumented change, and these pages may already be wrong about it.

Skip to content

Verb Vocabulary ​

Introduction ​

Storyfeed\Act provides common verbs as backed enum cases. Each stores an English verb, such as accept, and maps it to an Activity Streams 2.0 type, such as Accept.

Verbs are free-form strings, so you may use your own names, enum cases, or both.

Available Verbs ​

The verbs below are grouped by Activity Streams type. Case names start with a capital letter: Act::TentativelyAccept stores tentativelyAccept. The last column lists the 29 verbs Storyfeed registers without a Storyfeed::verbs() call.

Activity typeAct verbsRegistered by default
Createcreate, upload, draftcreate
Updateupdate, rename, amend, correct, supersede, complete, confirm, cancel, begin, end, pause, resume, extend, shorten, enable, disableupdate
Deletedelete, discarddelete
Undoundo, restore, reinstate, revert, void, withdrawundo
Addadd, attach, apply, recordadd
Removeremove, retire, archive, release, detachremove
Joinjoin, pairjoin
Leaveleaveleave
Offeroffer, send, propose, requestoffer
Inviteinviteinvite
Acceptaccept, agreeaccept
Rejectreject, declinereject
TentativeAccepttentativelyAccepttentativeAccept
TentativeRejecttentativelyRejecttentativeReject
Viewview, openview
Readread, downloadread
Listenlistenlisten
Announceannounce, remindannounce, share
Questionaskquestion
Flagflagflag
Likelikelike
Dislikedislikedislike
Followfollowfollow
Ignoreignoreignore
Blockblockblock
Arrivearrivearrive
Traveltraveltravel
Movemovemove

All verbs use present tense, such as send. The enum covers all 28 Activity Streams activity types.

For example, Act::Accept stores accept and serializes as "type": "Accept" with "sf:verb": "accept". Activity Verbs shows how to record with an enum case.

Registering Verbs ​

Pass a verb-to-type map to Storyfeed::verbs(). Use Act::only() to build the map from the cases your application records:

app/Providers/AppServiceProvider.phpboot()
php
use Storyfeed\Act;
use Storyfeed\Facades\Storyfeed;

Storyfeed::verbs(
    Act::only(
        Act::Create, Act::Update, Act::Accept, Act::Archive,
    ),
);

Register only the verbs your application records. Registering all 67 cases produces a verbs.dead finding for each unused verb.

Using Application Verbs ​

Register custom verbs as strings or in an enum implementing FeedVerb.

Domain actions such as reply, settle, deliver, approve, and sign are application-owned verbs. Register their Activity Streams types explicitly.

app/Providers/AppServiceProvider.phpboot()
php
use Storyfeed\ActivityStreams\ActivityType;
use Storyfeed\Facades\Storyfeed;

Storyfeed::verbs([
    'plate' => ActivityType::Create,
    'reply' => ActivityType::Create,
    'deliver' => ActivityType::Create,
    'settle' => ActivityType::Update,
    'approve' => ActivityType::Accept,
    'sign' => ActivityType::Accept,
]);

Combining Verb Enums ​

Storyfeed::verbs() merges registrations by default, so both vocabularies remain available.

app/Providers/AppServiceProvider.phpboot()
php
use App\Enums\ShopActivity;
use Storyfeed\Act;
use Storyfeed\Facades\Storyfeed;

Storyfeed::verbs(Act::only(Act::Create, Act::Confirm));
Storyfeed::verbs(ShopActivity::class);

Replacing the Registered Verbs ​

Pass merge: false to replace every registered verb, the shipped defaults included, with the given map:

app/Providers/AppServiceProvider.phpboot()
php
use App\Enums\ShopActivity;
use Storyfeed\Facades\Storyfeed;

Storyfeed::verbs(ShopActivity::class, merge: false);

Verb Enums ​

A backed string enum that implements Storyfeed\Contracts\FeedVerb can be registered with Storyfeed::verbs(ShopActivity::class) and passed wherever a verb is accepted. See Publishing From an Enum Case.

The FeedVerb Contract ​

MethodReturns
verb()the verb string stored on the activity
activityType()an ActivityType case, an extension type string kept as given, or null

When activityType() returns null, registering the enum maps the case to the type of the default verb with the same name, or to Activity when there is none.

AsFeedVerb Methods ​

The Storyfeed\Concerns\AsFeedVerb trait implements the contract: verb() returns the case's value and activityType() returns null. Override activityType() to declare a type. The trait also adds these methods to each case:

MethodReturns
of($object = null)a PendingActivity with this verb and the object
anonymous($object = null)the same, with no actor recorded
publish($object = null)the published Activity
record(object:, actor:, target:, …)the published Activity; takes the named arguments of Storyfeed::record(), except verb and anonymous
by(), to(), object() and the other role methods, objects(), the featuring…() methods, withoutFeature(), anonymously(), data(), publishedAt(), startsAt() and endsAt()a PendingActivity with this verb, after calling that method on it

Unregistered Verbs ​

Storyfeed registers the 29 verbs in the last column of Available Verbs without a Storyfeed::verbs() call.

Publishing any other verb before it is registered depends on verbs.strict:

verbs.strictResult
true, or null in the local and testing environmentsthrows Storyfeed\Exceptions\UnknownVerb
false, or null in other environmentspublishes; the activity serializes as "type": "Activity"

A verb containing a dot throws Storyfeed\Exceptions\DottedVerb when it is registered, declared or published, whatever verbs.strict says. See Naming Verbs.

Released under the MIT License.