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 type | Act verbs | Registered by default |
|---|---|---|
Create | create, upload, draft | create |
Update | update, rename, amend, correct, supersede, complete, confirm, cancel, begin, end, pause, resume, extend, shorten, enable, disable | update |
Delete | delete, discard | delete |
Undo | undo, restore, reinstate, revert, void, withdraw | undo |
Add | add, attach, apply, record | add |
Remove | remove, retire, archive, release, detach | remove |
Join | join, pair | join |
Leave | leave | leave |
Offer | offer, send, propose, request | offer |
Invite | invite | invite |
Accept | accept, agree | accept |
Reject | reject, decline | reject |
TentativeAccept | tentativelyAccept | tentativeAccept |
TentativeReject | tentativelyReject | tentativeReject |
View | view, open | view |
Read | read, download | read |
Listen | listen | listen |
Announce | announce, remind | announce, share |
Question | ask | question |
Flag | flag | flag |
Like | like | like |
Dislike | dislike | dislike |
Follow | follow | follow |
Ignore | ignore | ignore |
Block | block | block |
Arrive | arrive | arrive |
Travel | travel | travel |
Move | move | move |
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:
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.
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.
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:
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
| Method | Returns |
|---|---|
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:
| Method | Returns |
|---|---|
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.strict | Result |
|---|---|
true, or null in the local and testing environments | throws Storyfeed\Exceptions\UnknownVerb |
false, or null in other environments | publishes; 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.