Configuring event handlers in Umbraco UI Builder, the backoffice UI builder for Umbraco.
Umbraco UI Builder fires a number of notification events during regular operation to allow for extending of the default behaviour.
Umbraco UI Builder uses the same Notification Mechanism built into Umbraco v9+ and so uses the same registration process. First you will need to define a notification event handler for the event you wish to handle like below:
Then register your event handler in the ConfigureServices
method of your Startup.cs
file like below:
Raised when the repository Save
method is called and before the entity has been persisted. The notification contains an Entity
property with Before
and After
inner properties. These properties provide access to a copy of the currently persisted entity (or null if a new entity) and the updated entity that´s saved. Changes can be made to the After
entity and they will be persisted as part of the save operation. If the Cancel
property of the notification is set to true
then the save operation will be canceled and no changes will be saved.
Raised when the repository Save
method is called and after the entity has been persisted. The notification contains an Entity
property with Before
and After
inner properties. These properties provide access to a copy of the previously persisted entity (or null if a new entity) and the updated entity that´s saved.
Raised when the repository Delete
method is called and before the entity is deleted. The notification contains an Entity
property providing access to a copy of the entity about to be deleted. If the Cancel
property of notification is set to true
then the delete operation will be cancelled and entity won't be deleted.
Raised when the repository Delete
method is called and after the entity has been deleted. The notification contains an Entity
property providing access to a copy of the entity that´s deleted.
Raised when the repository is preparing a SQL query. The notification contains the collection alias + type, the NPoco Sql<ISqlContext>
object, and the where clause/order by clauses. These will be used to generate the SQL query.
Raised when the repository has repaired a SQL query. The notification contains the collection alias + type, the NPoco Sql<ISqlContext>
object and the where clause/order by clauses that was used to generate the SQL query.