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.

  1. Overview
  2. Available Events
    1. AssetContainerBlueprintFound
    2. AssetContainerCreating
    3. AssetContainerDeleted
    4. AssetContainerSaved
    5. AssetCreated
    6. AssetCreating
    7. AssetDeleting
    8. AssetDeleted
    9. AssetFolderDeleted
    10. AssetFolderSaved
    11. AssetSaved
    12. AssetSaving
    13. AssetUploaded
    14. BlueprintCreating
    15. BlueprintDeleting
    16. BlueprintDeleted
    17. BlueprintSaved
    18. CollectionDeleting
    19. CollectionDeleted
    20. CollectionCreated
    21. CollectionCreating
    22. CollectionSaved
    23. CollectionSaving
    24. CollectionTreeDeleted
    25. CollectionTreeSaved
    26. EntryBlueprintFound
    27. EntryCreated
    28. EntryCreating
    29. EntryDeleting
    30. EntryDeleted
    31. EntrySaved
    32. EntrySaving
    33. FieldsetCreating
    34. FieldsetDeleting
    35. FieldsetDeleted
    36. FieldsetSaved
    37. FormBlueprintFound
    38. FormCreating
    39. FormDeleting
    40. FormDeleted
    41. FormSaved
    42. FormSubmitted
    43. GlideCacheCleared
    44. GlideImageGenerated
    45. GlobalSetCreating
    46. GlobalSetDeleting
    47. GlobalSetDeleted
    48. GlobalSetSaved
    49. GlobalVariablesDeleting
    50. GlobalVariablesCreating
    51. GlobalVariablesBlueprintFound
    52. ImpersonationStarted
    53. ImpersonationEnded
    54. LicensesRefreshed
    55. LicenseSet
    56. NavDeleting
    57. NavDeleted
    58. NavSaved
    59. NavTreeSaved
    60. ResponseCreated
    61. RevisionDeleted
    62. RevisionSaving
    63. RevisionSaved
    64. RoleDeleted
    65. RoleSaved
    66. SearchIndexUpdated
    67. StacheCleared
    68. StacheWarmed
    69. StaticCacheCleared
    70. SubmissionCreated
    71. SubmissionCreating
    72. SubmissionDeleted
    73. SubmissionSaved
    74. TaxonomyCreating
    75. TaxonomyDeleting
    76. TaxonomyDeleted
    77. TaxonomySaved
    78. TermBlueprintFound
    79. TermCreating
    80. TermDeleting
    81. TermDeleted
    82. TermSaved
    83. UserBlueprintFound
    84. UserCreating
    85. UserDeleting
    86. UserDeleted
    87. UserGroupDeleted
    88. UserGroupSaved
    89. UserPasswordChanged
    90. UserRegistering
    91. UserRegistered
    92. UserSaved
    93. UrlInvalidated

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)
{
//
}
}

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

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

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

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

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

AssetCreated

Statamic\Events\AssetCreated

Dispatched after an asset has been created or uploaded.

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

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

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

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

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

AssetUploaded

Statamic\Events\AssetUploaded

Dispatched after an asset has been uploaded.

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

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

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

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

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

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

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

CollectionSaved

Statamic\Events\CollectionSaved

Dispatched after a collection has been saved.

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

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

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

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

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

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

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

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

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

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

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

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

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.

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)
{
//
}

GlideImageGenerated

Statamic\Events\GlideImageGenerated

Dispatched after Glide generates an image.

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

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

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

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

GlobalVariablesDeleting

Statamic\Events\GlobalVariablesDeleting

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

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

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

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

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

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

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)
{
//
}

LicenseSet

Statamic\Events\LicenseSet

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

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

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

Statamic\Events\NavDeleted

Dispatched after a nav has been deleted.

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

Statamic\Events\NavSaved

Dispatched after a nav has been saved.

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

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

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

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

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

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)
{
//
}

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)
{
//
}

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)
{
//
}

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

UrlInvalidated

Statamic\Events\UrlInvalidated

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

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

Submit improvements, related content, or suggestions through Github.

Betterify this page →