Skip to content Skip to footer navigation

Events

Events serve as a great way to decouple various aspects of the application, or even modify behavior or output of core functionality. A single event can have multiple listeners that do not depend on each other.

Overview#

Statamic will dispatch a number of events in various locations throughout the codebase.

To listen for events, simply create an event listener, type the event name, then handle the event.

use Statamic\Events\SomeEvent;
 
class SomeListener
{
public function handle(SomeEvent $event)
{
//
}
}
php
php

For applications with a app/Providers/EventServiceProvider.php file, you should also register the event listener in the $listen array:

protected $listen = [
'SomeEvent' => [
'SomeListener',
],
];
php
php

For a more in-depth explanation on events, please consult the Laravel documentation.

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;
}
php
php

AssetContainerCreating#

Statamic\Events\AssetContainerCreating

Dispatched before an asset container is created. You can return false to prevent it from being created.

public function handle(AssetContainerCreating $event)
{
$event->container;
}
php
php

AssetContainerDeleted#

Statamic\Events\AssetContainerDeleted

Dispatched after an asset container has been deleted.

public function handle(AssetContainerDeleted $event)
{
$event->container;
}
php
php

AssetContainerSaved#

Statamic\Events\AssetContainerSaved

Dispatched after an asset container has been saved.

public function handle(AssetContainerSaved $event)
{
$event->container;
}
php
php

AssetCreated#

Statamic\Events\AssetCreated

Dispatched after an asset has been created or uploaded.

public function handle(AssetCreated $event)
{
$event->asset;
}
php
php

AssetCreating#

Statamic\Events\AssetCreating

Dispatched before an asset is created or uploaded. You can return false to prevent it from being created.

public function handle(AssetCreating $event)
{
$event->asset;
}
php
php

AssetDeleting#

Statamic\Events\AssetDeleting

Dispatched before an asset is deleted. You can return false to prevent it from being deleted.

public function handle(AssetDeleting $event)
{
$event->asset;
}
php
php

AssetDeleted#

Statamic\Events\AssetDeleted

Dispatched after an asset has been deleted.

public function handle(AssetDeleted $event)
{
$event->asset;
}
php
php

AssetFolderDeleted#

Statamic\Events\AssetFolderDeleted

Dispatched after an asset folder has been deleted.

public function handle(AssetFolderDeleted $event)
{
$event->folder;
}
php
php

AssetFolderSaved#

Statamic\Events\AssetFolderSaved

Dispatched after an asset folder has been saved.

public function handle(AssetFolderSaved $event)
{
$event->folder;
}
php
php

AssetSaved#

Statamic\Events\AssetSaved

Dispatched after an asset has been saved.

public function handle(AssetSaved $event)
{
$event->asset;
}
php
php

AssetSaving#

Statamic\Events\AssetSaving

Dispatched before an asset is saved. You can return false to prevent it from being saved.

public function handle(AssetSaving $event)
{
$event->asset;
}
php
php

AssetUploaded#

Statamic\Events\AssetUploaded

Dispatched after an asset has been uploaded.

public function handle(AssetUploaded $event)
{
$event->asset;
}
php
php

BlueprintCreating#

Statamic\Events\BlueprintCreating

Dispatched before a blueprint is created. You can return false to prevent it from being creating.

public function handle(BlueprintCreating $event)
{
$event->blueprint;
}
php
php

BlueprintDeleting#

Statamic\Events\BlueprintDeleting

Dispatched before a blueprint is deleted. You can return false to prevent it from being deleted.

public function handle(BlueprintDeleting $event)
{
$event->blueprint;
}
php
php

BlueprintDeleted#

Statamic\Events\BlueprintDeleted

Dispatched after a blueprint has been deleted.

public function handle(BlueprintDeleted $event)
{
$event->blueprint;
}
php
php

BlueprintSaved#

Statamic\Events\BlueprintSaved

Dispatched after a blueprint has been saved.

public function handle(BlueprintSaved $event)
{
$event->blueprint;
}
php
php

CollectionDeleting#

Statamic\Events\CollectionDeleting

Dispatched before a collection is deleted. You can return false to prevent it from being deleted.

public function handle(CollectionDeleting $event)
{
$event->collection;
}
php
php

CollectionDeleted#

Statamic\Events\CollectionDeleted

Dispatched after a collection has been deleted.

public function handle(CollectionDeleted $event)
{
$event->collection;
}
php
php

CollectionCreated#

Statamic\Events\CollectionCreated

Dispatched after a collection has been created.

public function handle(CollectionCreated $event)
{
$event->collection;
}
php
php

CollectionCreating#

Statamic\Events\CollectionCreating

Dispatched before a collection is created. You can return false to prevent it from being created.

public function handle(CollectionCreating $event)
{
$event->collection;
}
php
php

CollectionSaved#

Statamic\Events\CollectionSaved

Dispatched after a collection has been saved.

public function handle(CollectionSaved $event)
{
$event->collection;
}
php
php

CollectionSaving#

Statamic\Events\CollectionSaving

Dispatched before a collection is saved. You can return false to prevent it from being saved.

public function handle(CollectionSaving $event)
{
$event->collection;
}
php
php

CollectionTreeDeleted#

Statamic\Events\CollectionTreeDeleted

Dispatched after a collection tree has been deleted.

public function handle(CollectionTreeDeleted $event)
{
$event->tree;
}
php
php

CollectionTreeSaved#

Statamic\Events\CollectionTreeSaved

Dispatched after a collection tree has been saved.

public function handle(CollectionTreeSaved $event)
{
$event->tree;
}
php
php

CollectionTreeSaving#

Statamic\Events\CollectionTreeSaving

Dispatched when a collection tree is being saved. You can return false to prevent it from being saved.

public function handle(CollectionTreeSaving $event)
{
$event->tree;
}
php
php

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;
}
php
php

EntryCreated#

Statamic\Events\EntryCreated

Dispatched after an entry has been created.

public function handle(EntryCreated $event)
{
$event->entry;
}
php
php

EntryCreating#

Statamic\Events\EntryCreating

Dispatched before an entry is created. You can return false to prevent it from being created.

public function handle(EntryCreating $event)
{
$event->entry;
}
php
php

EntryDeleting#

Statamic\Events\EntryDeleting

Dispatched before an entry is deleted. You can return false to prevent it from being deleted.

public function handle(EntryDeleting $event)
{
$event->entry;
}
php
php

EntryDeleted#

Statamic\Events\EntryDeleted

Dispatched after an entry has been deleted.

public function handle(EntryDeleted $event)
{
$event->entry;
}
php
php

EntrySaved#

Statamic\Events\EntrySaved

Dispatched after an entry has been saved.

public function handle(EntrySaved $event)
{
$event->entry;
}
php
php
Note

When an entry has multiple localizations, the EntrySaved event will be fired for each of those localizations. You may use the $event->isInitial() method to determine whether the localized entry from the event was the one originally being saved.

A troll pointing a teaching stick

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;
}
php
php

EntryScheduleReached#

Statamic\Events\EntryScheduleReached

Disptached whenever a scheduled entry reaches its target date. This event is used in multiple places such as updating search indexes and invalidating caches.

The event will be dispatched on the minute after the scheduled time.

public function handle(EntryScheduleReached $event)
{
$event->entry;
}
php
php

FieldsetCreating#

Statamic\Events\FieldsetCreating

Dispatched before a fieldset is created. You can return false to prevent it from being created.

public function handle(FieldsetCreating $event)
{
$event->fieldset;
}
php
php

FieldsetDeleting#

Statamic\Events\FieldsetDeleting

Dispatched before a fieldset is deleted. You can return false to prevent it from being deleted.

public function handle(FieldsetDeleting $event)
{
$event->fieldset;
}
php
php

FieldsetDeleted#

Statamic\Events\FieldsetDeleted

Dispatched after a fieldset has been deleted.

public function handle(FieldsetDeleted $event)
{
$event->fieldset;
}
php
php

FieldsetSaved#

Statamic\Events\FieldsetSaved

Dispatched after a fieldset has been saved.

public function handle(FieldsetSaved $event)
{
$event->fieldset;
}
php
php

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;
}
php
php

FormCreating#

Statamic\Events\FormCreating

Dispatched before a form is created. You can return false to prevent it from being created.

public function handle(FormCreating $event)
{
$event->form;
}
php
php

FormDeleting#

Statamic\Events\FormDeleting

Dispatched before a form is deleted. You can return false to prevent it from being deleted.

public function handle(FormDeleting $event)
{
$event->form;
}
php
php

FormDeleted#

Statamic\Events\FormDeleted

Dispatched after a form has been deleted.

public function handle(FormDeleted $event)
{
$event->form;
}
php
php

FormSaved#

Statamic\Events\FormSaved

Dispatched after a form has been saved.

public function handle(FormSaved $event)
{
$event->form;
}
php
php

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
}
php
php

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.']);
php
php

You may also just modify the submission object. You do not need to return anything.

GlideCacheCleared#

Statamic\Events\GlideCacheCleared

Dispatched after the Glide cache has been cleared, either via the php please glide:clear command or via the Cache Manager utility.

public function handle(GlideCacheCleared $event)
{
//
}
php
php

GlideImageGenerated#

Statamic\Events\GlideImageGenerated

Dispatched after Glide generates an image.

public function handle(GlideImageGenerated $event)
{
$event->path;
$event->params;
}
php
php

GlobalSetCreating#

Statamic\Events\GlobalSetCreating

Dispatched before a global set is created. You can return false to prevent it from being created.

public function handle(GlobalSetCreating $event)
{
$event->globals;
}
php
php

GlobalSetDeleting#

Statamic\Events\GlobalSetDeleting

Dispatched before a global set is deleted. You can return false to prevent it from being deleted.

public function handle(GlobalSetDeleting $event)
{
$event->globals;
}
php
php

GlobalSetDeleted#

Statamic\Events\GlobalSetDeleted

Dispatched after a global set has been deleted.

public function handle(GlobalSetDeleted $event)
{
$event->globals;
}
php
php

GlobalSetSaved#

Statamic\Events\GlobalSetSaved

Dispatched after a global set has been saved.

public function handle(GlobalSetSaved $event)
{
$event->globals;
}
php
php

GlobalVariablesCreated#

Statamic\Events\GlobalVariablesCreated

Dispatched after Global Variables have been created.

public function handle(GlobalVariablesCreated $event)
{
$event->variables;
}
php
php

GlobalVariablesCreating#

Statamic\Events\GlobalVariablesCreating

Dispatched before Global Variables are created. You can return false to prevent it from being created.

public function handle(GlobalVariablesCreating $event)
{
$event->variables;
}
php
php

GlobalVariablesDeleting#

Statamic\Events\GlobalVariablesDeleting

Dispatched after Global Variables have been deleted.

public function handle(GlobalVariablesDeleting $event)
{
$event->variables;
}
php
php

GlobalVariablesDeleted#

Statamic\Events\GlobalVariablesDeleted

Dispatched before Global Variables are deleted. You can return false to prevent it from being deleted.

public function handle(GlobalVariablesDeleted $event)
{
$event->variables;
}
php
php

GlobalVariablesSaved#

Statamic\Events\GlobalVariablesSaved

Dispatched after Global Variables have been saved.

public function handle(GlobalVariablesDeleting $event)
{
$event->variables;
}
php
php

GlobalVariablesSaving#

Statamic\Events\GlobalVariablesSaving

Dispatched before Global Variables are saved. You can return false to prevent it from being saved.

public function handle(GlobalVariablesSaving $event)
{
$event->variables;
}
php
php

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;
}
php
php

ImpersonationStarted#

Statamic\Events\ImpersonationStarted

Dispatched whenever a user starts impersonating another user.

public function handle(ImpersonationStarted $event)
{
$event->impersonator; // The other who started impersonating the other.
$event->impersonated; // The user being impersonated.
}
php
php

ImpersonationEnded#

Statamic\Events\ImpersonationEnded

Dispatched whenever a user finishes impersonating another user.

public function handle(ImpersonationEnded $event)
{
$event->impersonator; // The other who started impersonating the other.
$event->impersonated; // The user being impersonated.
}
php
php

LicensesRefreshed#

Statamic\Events\LicensesRefreshed

Dispatched when a user manually triggers a “Sync” of a site’s licenses via the Licenses utility.

public function handle(LicensesRefreshed $event)
{
//
}
php
php

LicenseSet#

Statamic\Events\LicenseSet

Dispatched after a license key has been set via the php please license:set command.

public function handle(LicenseSet $event)
{
//
}
php
php

LocalizedTermDeleted#

Statamic\Events\LocalizedTermDeleted

Dispatched after a taxonomy term has been deleted.

This event is similar to the TermDeleted event, however, instead of $term being a Term instance, it will be a LocalizedTerm instance.

public function handle(LocalizedTermDeleted $event)
{
$event->term;
}
php
php

LocalizedTermSaved#

Statamic\Events\LocalizedTermSaved

Dispatched after a taxonomy term has been saved.

This event is similar to the TermSaved event, however, instead of $term being a Term instance, it will be a LocalizedTerm instance.

public function handle(LocalizedTermSaved $event)
{
$event->term;
}
php
php

Statamic\Events\NavCreated

Dispatched after a nav has been created.

public function handle(NavCreated $event)
{
$event->nav;
}
php
php

Statamic\Events\NavCreating

Dispatched before a nav is created. You can return false to prevent it from being created.

public function handle(NavCreating $event)
{
$event->nav;
}
php
php

Statamic\Events\NavDeleting

Dispatched before a nav is deleted. You can return false to prevent it from being deleted.

public function handle(NavDeleting $event)
{
$event->nav;
}
php
php

Statamic\Events\NavDeleted

Dispatched after a nav has been deleted.

public function handle(NavDeleted $event)
{
$event->nav;
}
php
php

Statamic\Events\NavSaved

Dispatched after a nav has been saved.

public function handle(NavSaved $event)
{
$event->nav;
}
php
php

Statamic\Events\NavSaving

Dispatched before a nav is saved. You can return false to prevent it from being saved.

public function handle(NavSaving $event)
{
$event->nav;
}
php
php

Statamic\Events\NavTreeSaved

Dispatched after a nav tree has been saved.

public function handle(NavTreeSaved $event)
{
$event->tree;
}
php
php

Statamic\Events\NavTreeSaving

Dispatched when a nav tree is being saved. You can return false to prevent it from being saved.

public function handle(NavTreeSaving $event)
{
$event->tree;
}
php
php

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
}
php
php

RevisionDeleted#

Statamic\Events\RevisionDeleted

Dispatched after a revision of an entry has been deleted.

public function handle(RevisionDeleted $event)
{
$event->revision;
}
php
php

RevisionSaving#

Statamic\Events\RevisionSaving

Dispatched before a revision of an entry is saved. You can return false to prevent it from being saved.

public function handle(RevisionSaving $event)
{
$event->revision;
}
php
php

RevisionSaved#

Statamic\Events\RevisionSaved

Dispatched after a revision of an entry has been saved.

public function handle(RevisionSaved $event)
{
$event->revision;
}
php
php

RoleDeleted#

Statamic\Events\RoleDeleted

Dispatched after a role has been deleted.

public function handle(RoleDeleted $event)
{
$event->role;
}
php
php

RoleSaved#

Statamic\Events\RoleSaved

Dispatched after a role has been saved.

public function handle(RoleSaved $event)
{
$event->role;
}
php
php

SearchIndexUpdated#

Statamic\Events\SearchIndexUpdated

Dispatched when a search index is updated, either via the php please search:update command or via the Search utility.

public function handle(SearchIndexUpdated $event)
{
$event->index;
}
php
php

SiteCreated#

Statamic\Events\SiteCreated

Dispatched when a site is created via the Control Panel.

public function handle(SiteCreated $event)
{
$event->site;
}
php
php

SiteDeleted#

Statamic\Events\SiteDeleted

Dispatched when a site is deleted via the Control Panel.

public function handle(SiteDeleted $event)
{
$event->site;
}
php
php

SiteSaved#

Statamic\Events\SiteSaved

Dispatched when a site is saved via the Control Panel.

public function handle(SiteSaved $event)
{
$event->site;
}
php
php

StacheCleared#

Statamic\Events\StacheCleared

Dispatched after the Stache cache has been cleared, either via the php please stache:clear command or via the Cache Manager utility.

public function handle(StacheCleared $event)
{
//
}
php
php

StacheWarmed#

Statamic\Events\StacheWarmed

Dispatched after the Stache cache has been warmed, either via the php please stache:warm command or via the Cache Manager utility.

public function handle(StacheWarmed $event)
{
//
}
php
php

StaticCacheCleared#

Statamic\Events\StaticCacheCleared

Dispatched after the Static Cache has been cleared, either via the php please static:clear command or via the Cache Manager utility.

public function handle(StaticCacheCleared $event)
{
//
}
php
php

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;
}
php
php

If you’re looking to prevent a form being submitted or trigger validation errors, check out the FormSubmitted event.

SubmissionCreating#

Statamic\Events\SubmissionCreating

Dispatched before a submission is created. You can return false to prevent it from being created.

public function handle(SubmissionCreating $event)
{
$event->submission;
}
php
php

SubmissionDeleted#

Statamic\Events\SubmissionDeleted

Dispatched after a form submission has been deleted.

public function handle(SubmissionDeleted $event)
{
$event->submission;
}
php
php

SubmissionSaved#

Statamic\Events\SubmissionSaved

Dispatched after a form submission has been saved.

public function handle(SubmissionSaved $event)
{
$event->submission;
}
php
php

TaxonomyCreating#

Statamic\Events\TaxonomyCreating

Dispatched before a taxonomy is created. You can return false to prevent it from being created.

public function handle(TaxonomyCreating $event)
{
$event->taxonomy;
}
php
php

TaxonomyDeleting#

Statamic\Events\TaxonomyDeleting

Dispatched before a taxonomy is deleted. You can return false to prevent it from being deleted.

public function handle(TaxonomyDeleting $event)
{
$event->taxonomy;
}
php
php

TaxonomyDeleted#

Statamic\Events\TaxonomyDeleted

Dispatched after a taxonomy has been deleted.

public function handle(TaxonomyDeleted $event)
{
$event->taxonomy;
}
php
php

TaxonomySaved#

Statamic\Events\TaxonomySaved

Dispatched after a taxonomy has been saved.

public function handle(TaxonomySaved $event)
{
$event->taxonomy;
}
php
php

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;
}
php
php

TermCreating#

Statamic\Events\TermCreating

Dispatched before a taxonomy term is created. You can return false to prevent it from being created.

public function handle(TermCreating $event)
{
$event->term;
}
php
php

TermDeleting#

Statamic\Events\TermDeleting

Dispatched before a taxonomy term is deleted. You can return false to prevent it from being deleted.

public function handle(TermDeleting $event)
{
$event->term;
}
php
php

TermDeleted#

Statamic\Events\TermDeleted

Dispatched after a taxonomy term has been deleted.

This event is similar to the LocalizedTermDeleted event, however, instead of $term being a LocalizedTerm instance, it will be a Term instance.

public function handle(TermDeleted $event)
{
$event->term;
}
php
php

TermSaved#

Statamic\Events\TermSaved

Dispatched after a taxonomy term has been saved.

This event is similar to the LocalizedTermSaved event, however, instead of $term being a LocalizedTerm instance, it will be a Term instance.

public function handle(TermSaved $event)
{
$event->term;
}
php
php

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;
}
php
php

UserCreating#

Statamic\Events\UserCreating

Dispatched before a user is created. You can return false to prevent it from being created.

public function handle(UserCreating $event)
{
$event->user;
}
php
php

UserDeleting#

Statamic\Events\UserDeleting

Dispatched before a user is deleted. You can return false to prevent it from being deleted.

public function handle(UserDeleting $event)
{
$event->user;
}
php
php

UserDeleted#

Statamic\Events\UserDeleted

Dispatched after a user has been deleted.

public function handle(UserDeleted $event)
{
$event->user;
}
php
php

UserGroupDeleted#

Statamic\Events\UserGroupDeleted

Dispatched after a user group has been deleted.

public function handle(UserGroupDeleted $event)
{
$event->group;
}
php
php

UserGroupSaved#

Statamic\Events\UserGroupSaved

Dispatched after a user group has been saved.

public function handle(UserGroupSaved $event)
{
$event->group;
}
php
php

UserPasswordChanged#

Statamic\Events\UserPasswordChanged

Dispatched when the password of another user has been changed in the Control Panel.

public function handle(UserPasswordChanged $event)
{
$event->user;
}
php
php

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;
}
php
php

UserRegistered#

Statamic\Events\UserRegistered

Dispatched after a user is saved.

public function handle(UserRegistered $event)
{
$event->user;
}
php
php

UserSaved#

Statamic\Events\UserSaved

Dispatched after a user has been saved.

public function handle(UserSaved $event)
{
$event->user;
}
php
php

UrlInvalidated#

Statamic\Events\UrlInvalidated

Dispatched after a URL has been removed from the static cache.

public function handle(UrlInvalidated $event)
{
$event->url;
}
php
php