Overview
Statamic will dispatch a number of events in various locations throughout the codebase.
In a nutshell, you’d create an event listener or subscriber, connect them together in a service provider, then handle the event.
protected $listen = [ 'SomeEvent' => [ 'SomeListener', ],];
class SomeListener{ public function handle(SomeEvent $event) { // }}
Consult the Laravel event documentation for a more in-depth explanation on events.
If you’re creating an addon, you can quickly register event listeners or subscribers.
Available Events
AssetContainerBlueprintFound
Statamic\Events\AssetContainerBlueprintFound
Dispatched after Statamic finds the blueprint to be used for an asset in an asset container.
You may modify the blueprint here and it will be reflected in the publish form (and wherever else a blueprint is used). An example of when this would be useful is to add fields to the publish page on the fly.
public function handle(AssetContainerBlueprintFound $event){ $event->blueprint; $event->container;}
AssetContainerDeleted
Statamic\Events\AssetContainerDeleted
Dispatched after an asset container has been deleted.
public function handle(AssetContainerDeleted $event){ $event->container;}
AssetContainerSaved
Statamic\Events\AssetContainerSaved
Dispatched after an asset container has been saved.
public function handle(AssetContainerSaved $event){ $event->container;}
AssetDeleted
Statamic\Events\AssetDeleted
Dispatched after an asset has been deleted.
public function handle(AssetDeleted $event){ $event->asset;}
AssetFolderDeleted
Statamic\Events\AssetFolderDeleted
Dispatched after an asset folder has been deleted.
public function handle(AssetFolderDeleted $event){ $event->folder;}
AssetFolderSaved
Statamic\Events\AssetFolderSaved
Dispatched after an asset folder has been saved.
public function handle(AssetFolderSaved $event){ $event->folder;}
AssetSaved
Statamic\Events\AssetSaved
Dispatched after an asset has been saved.
public function handle(AssetSaved $event){ $event->asset;}
AssetUploaded
Statamic\Events\AssetUploaded
Dispatched after an asset has been uploaded.
public function handle(AssetUploaded $event){ $event->asset;}
BlueprintDeleted
Statamic\Events\BlueprintDeleted
Dispatched after a blueprint has been deleted.
public function handle(BlueprintDeleted $event){ $event->blueprint;}
BlueprintSaved
Statamic\Events\BlueprintSaved
Dispatched after a blueprint has been saved.
public function handle(BlueprintSaved $event){ $event->blueprint;}
CollectionDeleted
Statamic\Events\CollectionDeleted
Dispatched after a collection has been deleted.
public function handle(CollectionDeleted $event){ $event->collection;}
CollectionCreated
Statamic\Events\CollectionCreated
Dispatched after a collection has been created.
public function handle(CollectionCreated $event){ $event->collection;}
CollectionSaved
Statamic\Events\CollectionSaved
Dispatched after a collection has been saved.
public function handle(CollectionSaved $event){ $event->collection;}
CollectionTreeDeleted
Statamic\Events\CollectionTreeDeleted
Dispatched after a collection tree has been deleted.
public function handle(CollectionTreeDeleted $event){ $event->tree;}
CollectionTreeSaved
Statamic\Events\CollectionTreeSaved
Dispatched after a collection tree has been saved.
public function handle(CollectionTreeSaved $event){ $event->tree;}
EntryBlueprintFound
Statamic\Events\EntryBlueprintFound
Dispatched after Statamic finds the blueprint to be used for an entry.
You may modify the blueprint here and it will be reflected in the publish form (and wherever else a blueprint is used). An example of when this would be useful is to add a section to a blueprint in the publish page on the fly.
public function handle(EntryBlueprintFound $event){ $event->blueprint; $event->entry;}
EntryCreated
Statamic\Events\EntryCreated
Dispatched after an entry has been created.
public function handle(EntryCreated $event){ $event->entry;}
EntryDeleted
Statamic\Events\EntryDeleted
Dispatched after an entry has been deleted.
public function handle(EntryDeleted $event){ $event->entry;}
EntrySaved
Statamic\Events\EntrySaved
Dispatched after an entry has been saved.
public function handle(EntrySaved $event){ $event->entry;}
EntrySaving
Statamic\Events\EntrySaving
Dispatched before an entry is saved. You can return false
to prevent it from being saved.
public function handle(EntrySaving $event){ $event->entry;}
FieldsetDeleted
Statamic\Events\FieldsetDeleted
Dispatched after a fieldset has been deleted.
public function handle(FieldsetDeleted $event){ $event->fieldset;}
FieldsetSaved
Statamic\Events\FieldsetSaved
Dispatched after a fieldset has been saved.
public function handle(FieldsetSaved $event){ $event->fieldset;}
FormBlueprintFound
Statamic\Events\FormBlueprintFound
Dispatched after Statamic finds the blueprint to be used for a form.
You may modify the blueprint here and it will be reflected in the publish form (and wherever else a blueprint is used). An example of when this would be useful is to add a section to a blueprint in the publish page on the fly.
public function handle(FormBlueprintFound $event){ $event->blueprint; $event->form;}
FormDeleted
Statamic\Events\FormDeleted
Dispatched after a form has been deleted.
public function handle(FormDeleted $event){ $event->form;}
FormSaved
Statamic\Events\FormSaved
Dispatched after a form has been saved.
public function handle(FormSaved $event){ $event->form;}
FormSubmitted
Statamic\Events\FormSubmitted
Dispatched when a Form is submitted on the front-end, before the Submission is created.
public function handle(FormSubmitted $event){ $event->submission; // The Submission object}
You can return false
to prevent the submission, but appear to the user as though it succeeded.
If you’d like to show validation errors, you may throw an Illuminate\Validation\ValidationException
:
throw ValidationException::withMessages(['You did something wrong.']);
You may also just modify the submission object. You do not need to return
anything.
GlideImageGenerated
Statamic\Events\GlideImageGenerated
Dispatched after Glide generates an image.
public function handle(GlideImageGenerated $event){ $event->path; $event->params;}
GlobalSetDeleted
Statamic\Events\GlobalSetDeleted
Dispatched after a global set has been deleted.
public function handle(GlobalSetDeleted $event){ $event->globals;}
GlobalSetSaved
Statamic\Events\GlobalSetSaved
Dispatched after a global set has been saved.
public function handle(GlobalSetSaved $event){ $event->globals;}
GlobalVariablesBlueprintFound
Statamic\Events\GlobalVariablesBlueprintFound
Dispatched after Statamic finds the blueprint to be used for a variables in a global set. (Variables meaning the globals localized to a particular site)
You may modify the blueprint here and it will be reflected in the publish form (and wherever else a blueprint is used). An example of when this would be useful is to add a section to a blueprint in the publish page on the fly.
public function handle(GlobalVariablesBlueprintFound $event){ $event->blueprint; $event->globals;}
NavDeleted
Statamic\Events\NavDeleted
Dispatched after a nav has been deleted.
public function handle(NavDeleted $event){ $event->nav;}
NavSaved
Statamic\Events\NavSaved
Dispatched after a nav has been saved.
public function handle(NavSaved $event){ $event->nav;}
NavTreeSaved
Statamic\Events\NavTreeSaved
Dispatched after a nav tree has been saved.
public function handle(NavTreeSaved $event){ $event->tree;}
ResponseCreated
Statamic\Events\ResponseCreated
Dispatched after Statamic finishes creating the response to send to the front-end. You may wish to modify the response to add headers, etc.
public function handle(ResponseCreated $event){ $event->response; // The Response object}
RevisionDeleted
Statamic\Events\RevisionDeleted
Dispatched after a revision of an entry has been deleted.
public function handle(RevisionDeleted $event){ $event->revision;}
RevisionSaved
Statamic\Events\RevisionSaved
Dispatched after a revision of an entry has been saved.
public function handle(RevisionSaved $event){ $event->revision;}
RoleDeleted
Statamic\Events\RoleDeleted
Dispatched after a role has been deleted.
public function handle(RoleDeleted $event){ $event->role;}
RoleSaved
Statamic\Events\RoleSaved
Dispatched after a role has been saved.
public function handle(RoleSaved $event){ $event->role;}
SubmissionCreated
Statamic\Events\SubmissionCreated
Dispatched after a form submission has been created. This happens after has a form has been submitted on the front-end.
public function handle(SubmissionCreated $event){ $event->submission;}
If you’re looking to prevent a form being submitted or trigger validation errors, check out the FormSubmitted event.
SubmissionDeleted
Statamic\Events\SubmissionDeleted
Dispatched after a form submission has been deleted.
public function handle(SubmissionDeleted $event){ $event->submission;}
SubmissionSaved
Statamic\Events\SubmissionSaved
Dispatched after a form submission has been saved.
public function handle(SubmissionSaved $event){ $event->submission;}
TaxonomyDeleted
Statamic\Events\TaxonomyDeleted
Dispatched after a taxonomy has been deleted.
public function handle(TaxonomyDeleted $event){ $event->taxonomy;}
TaxonomySaved
Statamic\Events\TaxonomySaved
Dispatched after a taxonomy has been saved.
public function handle(TaxonomySaved $event){ $event->taxonomy;}
TermBlueprintFound
Statamic\Events\TermBlueprintFound
Dispatched after Statamic finds the blueprint to be used for a taxonomy term.
You may modify the blueprint here and it will be reflected in the publish form (and wherever else a blueprint is used). An example of when this would be useful is to add a section to a blueprint in the publish page on the fly.
public function handle(TermBlueprintFound $event){ $event->blueprint; $event->term;}
TermDeleted
Statamic\Events\TermDeleted
Dispatched after a taxonomy term has been deleted.
public function handle(TermDeleted $event){ $event->term;}
TermSaved
Statamic\Events\TermSaved
Dispatched after a taxonomy term has been saved.
public function handle(TermSaved $event){ $event->term;}
UserBlueprintFound
Statamic\Events\UserBlueprintFound
Dispatched after Statamic finds the blueprint to be used for a user.
You may modify the blueprint here and it will be reflected in the publish form (and wherever else a blueprint is used). An example of when this would be useful is to add a section to a blueprint in the publish page on the fly.
public function handle(UserBlueprintFound $event){ $event->blueprint;}
UserDeleted
Statamic\Events\UserDeleted
Dispatched after a user has been deleted.
public function handle(UserDeleted $event){ $event->user;}
UserGroupDeleted
Statamic\Events\UserGroupDeleted
Dispatched after a user group has been deleted.
public function handle(UserGroupDeleted $event){ $event->group;}
UserGroupSaved
Statamic\Events\UserGroupSaved
Dispatched after a user group has been saved.
public function handle(UserGroupSaved $event){ $event->group;}
UserRegistering
Statamic\Events\UserRegistering
Dispatched before a user is saved.
You can return false to prevent the submission, but appear to the user as though it succeeded.
public function handle(UserRegistering $event){ $event->user;}
UserRegistered
Statamic\Events\UserRegistered
Dispatched after a user is saved.
public function handle(UserRegistered $event){ $event->user;}
UserSaved
Statamic\Events\UserSaved
Dispatched after a user has been saved.
public function handle(UserSaved $event){ $event->user;}