Page Builder > References
Lifecycle Events
Learn about Page Builder lifecycle events, how they work and how to subscribe to a lifecycle event.
- what are lifecycle events
- how lifecycle events work
- how to subscribe to a lifecycle event
Overview
In our Page Builder we provide lifecycle events available for you to hook into.
Lifecycle events are triggered before (onBefore
keyword) and after (onAfter
keyword) the data is stored into the database.
With onBefore
events you can change the data that is being stored into the database, so be careful with that.
With the lifecycle events you can hook into a number of different operations, for example:
- change the page data which is going to be stored
- notify another system that new page was stored
System
onBeforeInstall
This event is triggered before the installation of the Page Builder and insertion of initial Welcome to Webiny
and Not Found
pages.
Event Arguments
Property | Description |
---|---|
tenant | ID of the current tenant |
How to Subscribe to This Event?
onAfterInstall
This event is triggered after the installation of the Page Builder and insertion of initial Welcome to Webiny
and Not Found
pages.
Event Arguments
Property | Description |
---|---|
tenant | ID of the current tenant |
How to Subscribe to This Event?
Settings
onBeforeSettingsUpdate
This event is triggered before settings data is going to be stored.
Event Arguments
Property | Description |
---|---|
original | Settings object which was received from the database |
settings | Settings object which was changed by user input |
meta | Metadata |
meta.diff.pages | Array which contains which pages were changed |
How to Subscribe to This Event?
onAfterSettingsUpdate
This event is triggered after settings data was stored.
Event Arguments
Property | Description |
---|---|
original | Settings object which was received from the database |
settings | Settings object which was changed by user input |
meta | Metadata |
meta.diff.pages | Array which contains calculated page changes |
How to Subscribe to This Event?
Categories
onBeforeCategoryCreate
This event is triggered before new category is stored into the database.
Event Arguments
Property | Description |
---|---|
category | Category object which is going to be stored |
How to Subscribe to This Event?
onAfterCategoryCreate
This event is triggered after new category is stored into the database.
Event Arguments
Property | Description |
---|---|
category | Category object which was stored |
How to Subscribe to This Event?
onBeforeCategoryUpdate
This event is triggered before existing category is updated and stored.
Event Arguments
Property | Description |
---|---|
original | Category object which was received from the database |
category | Category object which is going to be stored |
How to Subscribe to This Event?
onAfterCategoryUpdate
This event is triggered after existing category is updated and stored.
Event Arguments
Property | Description |
---|---|
original | Category object which was received from the database |
category | Category object which was stored |
How to Subscribe to This Event?
onBeforeCategoryDelete
This event is triggered before category is deleted from the database.
Event Arguments
Property | Description |
---|---|
category | Category object which is going to be deleted |
How to Subscribe to This Event?
onAfterCategoryDelete
This event is triggered after category is deleted from the database.
Event Arguments
Property | Description |
---|---|
category | Category object which was deleted |
How to Subscribe to This Event?
Menus
onBeforeMenuCreate
This event is triggered before new menu is stored into the database.
Event Arguments
Property | Description |
---|---|
input | Input received from user |
menu | Menu object which is going to be stored |
How to Subscribe to This Event?
onAfterMenuCreate
This event is triggered after new menu is stored into the database.
Event Arguments
Property | Description |
---|---|
input | Input received from user |
menu | Menu object which was stored |
How to Subscribe to This Event?
onBeforeMenuUpdate
This event is triggered before existing menu is changed and stored.
Event Arguments
Property | Description |
---|---|
input | Input received from user |
original | Menu object which was received from the database |
menu | Menu object which is going to be stored |
How to Subscribe to This Event?
onAfterMenuUpdate
This event is triggered after existing menu is changed and stored.
Event Arguments
Property | Description |
---|---|
input | Input received from user |
original | Menu object which was received from the database |
menu | Menu object which was stored |
How to Subscribe to This Event?
onBeforeMenuDelete
This event is triggered before existing menu is deleted from the database.
Event Arguments
Property | Description |
---|---|
menu | Menu object which is going to be deleted |
How to Subscribe to This Event?
onAfterMenuDelete
This event is triggered after existing menu is deleted from the database.
Event Arguments
Property | Description |
---|---|
menu | Menu object which was deleted |
How to Subscribe to This Event?
Page Elements
onBeforePageElementCreate
This event is triggered before new page element is stored into the database.
Event Arguments
Property | Description |
---|---|
pageElement | Page element object which is going to be stored |
How to Subscribe to This Event?
onAfterPageElementCreate
This event is triggered after new page element is stored into the database.
Event Arguments
Property | Description |
---|---|
pageElement | Page element object which is stored |
How to Subscribe to This Event?
onBeforePageElementUpdate
This event is triggered before existing page element is changed and stored.
Event Arguments
Property | Description |
---|---|
original | Page element object which was received from the database |
pageElement | Page element object which is going to be stored |
How to Subscribe to This Event?
onAfterPageElementUpdate
This event is triggered after existing page element is changed and stored.
Event Arguments
Property | Description |
---|---|
original | Page element object which was received from the database |
pageElement | Page element object which is stored |
How to Subscribe to This Event?
onBeforePageElementDelete
This event is triggered before page element is deleted from the database.
Event Arguments
Property | Description |
---|---|
pageElement | Page element object which is going to be deleted |
How to Subscribe to This Event?
onAfterPageElementDelete
This event is triggered after page element is deleted from the database.
Event Arguments
Property | Description |
---|---|
pageElement | Page element object which was deleted |
How to Subscribe to This Event?
Pages
onBeforePageCreate
This event is triggered before a new page is stored into the database. This event is not triggered when creating a page from another page.
Event Arguments
Property | Description |
---|---|
page | Page object which is going to be stored |
How to Subscribe to This Event?
onAfterPageCreate
This event is triggered after new page is stored into the database.
Event Arguments
Property | Description |
---|---|
page | Page object which was stored |
How to Subscribe to This Event?
onBeforePageCreateFrom
This event is triggered before a new page, which is created from another page, is stored into the database.
Event Arguments
Property | Description |
---|---|
original | Page object which is the base for a new page |
page | Page object which is going to be stored |
How to Subscribe to This Event?
onAfterPageCreateFrom
This event is triggered after a new page, which is created from another page, is stored into the database.
Event Arguments
Property | Description |
---|---|
original | Page object which is the base for a new page |
page | Page object which was stored |
How to Subscribe to This Event?
onBeforePageUpdate
This event is triggered before a page is changed and stored into the database.
Event Arguments
Property | Description |
---|---|
original | Page object which was received from the database |
page | Page object which is going to be stored |
How to Subscribe to This Event?
onAfterPageUpdate
This event is triggered after a page changed and stored into the database.
Event Arguments
Property | Description |
---|---|
original | Page object which was received from the database |
page | Page object which was stored |
How to Subscribe to This Event?
onBeforePageDelete
This event is triggered before a page is deleted from the database.
Event Arguments
Property | Description |
---|---|
page | Page object which is going to be deleted |
How to Subscribe to This Event?
onAfterPageDelete
This event is triggered after a page is deleted from the database.
Event Arguments
Property | Description |
---|---|
page | Page object which was deleted |
How to Subscribe to This Event?
onBeforePagePublish
This event is triggered before a page is changed and stored into the database as the published one.
Event Arguments
Property | Description |
---|---|
publishedPage | Page object that is set as the published one in the database - published revision of page we are publishing |
latestPage | Page object of the last revision of the page we are publishing |
page | Page object which is going to be published |
How to Subscribe to This Event?
onAfterPagePublish
This event is triggered after a page is changed and stored into the database as the published one.
Event Arguments
Property | Description |
---|---|
publishedPage | Page object that is set as the published one in the database - published revision of page we are publishing |
latestPage | Page object of the last revision of the page we are publishing |
page | Page object which was published |
How to Subscribe to This Event?
onBeforePageUnpublish
This event is triggered before a page is changed and stored into the database.
Event Arguments
Property | Description |
---|---|
latestPage | Page object of the last revision of the page we are unpublishing |
page | Page object which is going to be unpublished |
How to Subscribe to This Event?
onAfterPageUnpublish
This event is triggered after a page is changed and stored into the database.
Event Arguments
Property | Description |
---|---|
latestPage | Page object of the last revision of the page we are unpublishing |
page | Page object which was unpublished |
How to Subscribe to This Event?
onBeforePageRequestChanges
This event is triggered before a page is marked as Requested Changes status and stored into the database.
Event Arguments
Property | Description |
---|---|
latestPage | Page object of the last revision of the page we are requesting changes on |
page | Page object which is going to be set into Requested Changes status |
How to Subscribe to This Event?
onAfterPageRequestChanges
This event is triggered after a page is marked as Requested Changes status and stored into the database.
Event Arguments
Property | Description |
---|---|
latestPage | Page object of the last revision of the page we are requesting changes on |
page | Page object which was set into Requested Changes status and stored |
How to Subscribe to This Event?
onBeforePageRequestReview
This event is triggered before a page is marked as Requested Review status and stored into the database.
Event Arguments
Property | Description |
---|---|
latestPage | Page object of the last revision of the page we are requesting review on |
page | Page object which is going to be set into Requested Review status |
How to Subscribe to This Event?
onAfterPageRequestReview
This event is triggered after a page is marked as Requested Review status and stored into the database.
Event Arguments
Property | Description |
---|---|
latestPage | Page object of the last revision of the page we are requesting review on |
page | Page object which was set into Requested Review status and stored |
How to Subscribe to This Event?
Please, be aware that you can change what ever you want on the object before it is stored into the database, so be careful with changing the data.
Registering Lifecycle Event Subscriptions
For the subscriptions (your code) to be run, you must register it in the createHandler
in the api/code/graphql/src/index.ts
file.
Please, be aware that the order of subscribing matters, so if you want some event subscription to be executed before some other one, add it first.