From ff4f6591c81fd02e91eb8655de2a5db9f5476068 Mon Sep 17 00:00:00 2001 From: "Alina-Magdalena Tincas (Umbraco HQ)" Date: Wed, 10 Apr 2024 15:52:22 +0200 Subject: [PATCH 1/5] v13 initial structure --- 13/umbraco-cms/SUMMARY.md | 16 +- .../reference/dive-into-the-code.md | 2 +- .../reference/notifications/README.md | 453 ++++++++++++------ .../cacherefresher-notifications.md | 11 +- .../contentservice-notifications.md | 41 +- .../contentypeservice-notifications.md | 134 ------ .../creating-and-publishing-notifications.md | 4 +- .../datatypeservice-notifications.md | 116 ----- .../notifications/determining-new-entity.md | 6 +- .../fileservice-notifications.md | 210 -------- .../notifications/hot-vs-cold-restarts.md | 2 +- .../localizationservice-notifications.md | 135 ------ .../mediaservice-notifications.md | 19 +- .../mediatypeservice-notifications.md | 134 ------ .../memberservice-notifications.md | 15 +- .../membertypeservice-notifications.md | 134 ------ .../notifications/notification-handler.md | 167 +++++++ .../relationservice-notifications.md | 141 ------ .../sendingallowedchildrennotifications.md | 4 + ...mbracoapplicationlifetime-notifications.md | 9 - 20 files changed, 523 insertions(+), 1230 deletions(-) delete mode 100644 13/umbraco-cms/reference/notifications/contentypeservice-notifications.md delete mode 100644 13/umbraco-cms/reference/notifications/datatypeservice-notifications.md delete mode 100644 13/umbraco-cms/reference/notifications/fileservice-notifications.md delete mode 100644 13/umbraco-cms/reference/notifications/localizationservice-notifications.md delete mode 100644 13/umbraco-cms/reference/notifications/mediatypeservice-notifications.md delete mode 100644 13/umbraco-cms/reference/notifications/membertypeservice-notifications.md create mode 100644 13/umbraco-cms/reference/notifications/notification-handler.md delete mode 100644 13/umbraco-cms/reference/notifications/relationservice-notifications.md diff --git a/13/umbraco-cms/SUMMARY.md b/13/umbraco-cms/SUMMARY.md index c9803e2b92a..30643169450 100644 --- a/13/umbraco-cms/SUMMARY.md +++ b/13/umbraco-cms/SUMMARY.md @@ -307,19 +307,13 @@ * [PDF indexes and multisearchers](reference/searching/examine/pdfindex-multisearcher.md) * [Quick-start](reference/searching/examine/quick-start.md) * [Using Notifications](reference/notifications/README.md) - * [CacheRefresher Notifications](reference/notifications/cacherefresher-notifications.md) - * [ContentService Notifications](reference/notifications/contentservice-notifications.md) - * [ContentTypeService Notifications](reference/notifications/contentypeservice-notifications.md) + * [Notification Handler](reference/notifications/notification-handler.md) + * [CacheRefresher Notifications Example](reference/notifications/cacherefresher-notifications.md) + * [ContentService Notifications Example](reference/notifications/contentservice-notifications.md) * [Creating And Publishing Notifications](reference/notifications/creating-and-publishing-notifications.md) - * [DataTypeService Notifications](reference/notifications/datatypeservice-notifications.md) * [Determining if an entity is new](reference/notifications/determining-new-entity.md) - * [FileService Notifications](reference/notifications/fileservice-notifications.md) - * [LocalizationService Events](reference/notifications/localizationservice-notifications.md) - * [MediaService Notifications](reference/notifications/mediaservice-notifications.md) - * [MediaTypeService Notifications](reference/notifications/mediatypeservice-notifications.md) - * [MemberService Notifications](reference/notifications/memberservice-notifications.md) - * [MemberTypeService Notifications](reference/notifications/membertypeservice-notifications.md) - * [RelationService Notifications](reference/notifications/relationservice-notifications.md) + * [MediaService Notifications Example](reference/notifications/mediaservice-notifications.md) + * [MemberService Notifications Example](reference/notifications/memberservice-notifications.md) * [Sending Allowed Children Notification](reference/notifications/sendingallowedchildrennotifications.md) * [Umbraco Application Lifetime Notifications](reference/notifications/umbracoapplicationlifetime-notifications.md) * [EditorModel Notifications](reference/notifications/editormodel-notifications/README.md) diff --git a/13/umbraco-cms/reference/dive-into-the-code.md b/13/umbraco-cms/reference/dive-into-the-code.md index 9f5697838af..37436f42388 100644 --- a/13/umbraco-cms/reference/dive-into-the-code.md +++ b/13/umbraco-cms/reference/dive-into-the-code.md @@ -10,7 +10,7 @@ The developers' Reference section primarily consists of API references of the di The section also includes documentation about the different configuration options, security, advanced templating, and searching. -
ConfigurationMost configuration in Umbraco CMS is handled via the appSettings.json file.configurationsetup-image.png
TemplatingWork with MVC views and Razor templates to build the frontend for your Umbraco CMS website.templatingdesign.png
Querying & ModelsEverything you need to extend your templates with filters, models, and more advanced queries.queryingdatap-image.png
Routing and ControllersDive into working with routers and controllers for customizing your Umbraco CMS even further.routingcontrollers-image.png
SecurityFind everything you need related to keeping your Umbraco CMS website secure.securitysecurity-imag.png
SearchingLearn about Examine and Lucene which are tools utilized in Umbraco for the search functionality.searchingsearching-image.png
NotificationsLearn how to use notifications to hook into the workflow processes for the backoffice.fileservice-notifications.mdnotifications-image.png
CachingLearn how to implement caching features in the Umbraco CMS application.cachecaching-image.png
API DocumentationDive into the deep end and start exploring the different sections of the Umbraco CMS API.api-documentation.mdapi-docs-image.png
+
ConfigurationMost configuration in Umbraco CMS is handled via the appSettings.json file.configurationsetup-image.png
TemplatingWork with MVC views and Razor templates to build the frontend for your Umbraco CMS website.templatingdesign.png
Querying & ModelsEverything you need to extend your templates with filters, models, and more advanced queries.queryingdatap-image.png
Routing and ControllersDive into working with routers and controllers for customizing your Umbraco CMS even further.routingcontrollers-image.png
SecurityFind everything you need related to keeping your Umbraco CMS website secure.securitysecurity-imag.png
SearchingLearn about Examine and Lucene which are tools utilized in Umbraco for the search functionality.searchingsearching-image.png
NotificationsLearn how to use notifications to hook into the workflow processes for the backoffice.Notificationsnotifications-image.png
CachingLearn how to implement caching features in the Umbraco CMS application.cachecaching-image.png
API DocumentationDive into the deep end and start exploring the different sections of the Umbraco CMS API.api-documentation.mdapi-docs-image.png
## Also in this section diff --git a/13/umbraco-cms/reference/notifications/README.md b/13/umbraco-cms/reference/notifications/README.md index 9f69b92bfe0..06cb188e501 100644 --- a/13/umbraco-cms/reference/notifications/README.md +++ b/13/umbraco-cms/reference/notifications/README.md @@ -1,3 +1,7 @@ +--- +description: Get started with Notifications. +--- + # Using Notifications Umbraco uses Notifications (similar to the Observer pattern) to allow you to hook into the workflow process for the backoffice. For example, notifications allow you to execute some code every time a page is published. @@ -10,192 +14,349 @@ Available notifications typically exist in pairs, with "before" and "after" noti The notification to use depends on what you want to achieve. If you want to be able to cancel the action, you would use the `CancelOperation` method on the "before" notification. See the sample in [ContentService Notifications](contentservice-notifications.md). If you want to execute some code after the publishing has succeeded, then you would use the "after" notification. -### Notification handlers lifetime +## Registering Notifications + +Check the [Notification Handler](./notification-handler.md) article to learn more about notification handlers lifetime, async notification handler and how to register the notification handlers. + +## List of Notifications + +Below you can find a list of most used object notifications. + +You can find a list of all supported notifications in the [API Docs](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.html). + +### Content, Media, and Member notifications + +
+ +**ContentService** Notifications + +The ContentService class is the most commonly used type when extending Umbraco using notifications. ContentService implements IContentService. It provides access to operations involving IContent. + +Below you can find a list of the most common ContentService object notifications. + +* [ContentSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentSavingNotification.html) + +* [ContentSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentSavedNotification.html) + +* [ContentPublishingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentPublishingNotification.html) + +* [ContentPublishedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentPublishedNotification.html) + +* [ContentUnpublishingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentUnpublishingNotification.html) + +* [ContentUnpublishedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentUnpublishedNotification.html) + +* [ContentCopyingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentCopyingNotification.html) + +* [ContentCopiedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentCopiedNotification.html) + +* [ContentMovingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovingNotification.html) + +* [ContentMovedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovedNotification.html) + +* [ContentMovingToRecycleBinNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovingToRecycleBinNotification.html) + +* [ContentMovedToRecycleBinNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovedToRecycleBinNotification.html) + +* [ContentDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletingNotification.html) + +* [ContentDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletedNotification.html) + +* [ContentDeletingVersionsNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletingVersionsNotification.html) + +* [ContentDeletedVersionsNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletedVersionsNotification.html) + +* [ContentRollingBackNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentRollingBackNotification.html) + +* [ContentRolledBackNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentRolledBackNotification.html) + +* [ContentSendingToPublishNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentSendingToPublishNotification.html) + +* [ContentSentToPublishNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentSentToPublishNotification.html) + +* [ContentEmptyingRecycleBinNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentEmptyingRecycleBinNotification.html) + +* [ContentEmptiedRecycleBinNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentEmptiedRecycleBinNotification.html) + +* [ContentSavedBlueprintNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentSavedBlueprintNotification.html) + +* [ContentDeletedBlueprintNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletedBlueprintNotification.html) + +
+ +
+ +**MediaService** Notifications + +Below you can find a list of the most common MediaService object notifications. + +* [MediaSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaSavingNotification.html) + +* [MediaSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaSavedNotification.html) + +* [MediaMovingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovingNotification.html) + +* [MediaMovedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovedNotification.html) + +* [MediaMovingToRecycleBinNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovingToRecycleBinNotification.html) + +* [MediaMovedToRecycleBinNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovedToRecycleBinNotification.html) + +* [MediaDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletingNotification.html) + +* [MediaDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletedNotification.html) + +* [MediaDeletingVersionsNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletingVersionsNotification.html) + +* [MediaDeletedVersionsNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletedVersionsNotification.html) + +
+ +
+ +**MemberService** Notifications + +The MemberService implements IMemberService and provides access to operations involving IMember. + +Below you can find a list of the most common MemberService object notifications. + +* [MemberSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberSavingNotification.html) + +* [MemberSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberSavedNotification.html) + +* [MemberDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberDeletingNotification.html) + +* [MemberDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberDeletedNotification.html) + +* [AssignedMemberRolesNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.AssignedMemberRolesNotification.html) + +* [RemovedMemberRolesNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.RemovedMemberRolesNotification.html) + +
+ +### Other notifications + +
+ +**ContentTypeService** Notifications + +The ContentTypeService class implements IContentTypeService. It provides access to operations involving IContentType. + +Below you can find a list of the most common ContentTypeService object notifications. + +* [ContentTypeSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeSavingNotification.html) + +* [ContentTypeSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeSavedNotification.html) -It's important to know that the handlers you create and register to receive notifications will be **transient**. This means that they will be initialized every time they receive a notification. You can therefore not rely on them having a specific state based on previous notifications. +* [ContentTypeDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeDeletingNotification.html) -As an example, you cannot do the following: +* [ContentTypeDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeDeletedNotification.html) -1. Create a list in a handler. -2. Add something when a notification is received. -3. Check if that list contains what you added in an earlier notification. +* [ContentTypeMovingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeMovingNotification.html) -When following the steps above, the list will always be empty because the object has only been initialized. +* [ContentTypeMovedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeMovedNotification.html) -If you need persistence between notifications, we recommend you move that functionality into a service or similar. You can then register it with the DI container, and inject it into your handler. +* [ContentTypeChangedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeChangedNotification.html) -As previously mentioned, many notifications exist in pairs, with a "before" and "after" notification. There may be cases where you want to add some information to the "before" notification, which will then be available to your "after" notification handler. In order to support this, the notification "pairs" are **stateful**. This means the notifications contain a dictionary that is shared between the "before" and "after" notifications. You can add values to the dictionary, and later retrieve them like this: +
-```csharp -public void Handle(TemplateSavingNotification notification) -{ - notification.State["SomeKey"] = "Some Value Relevant to the \"after\" notification handler"; -} +
+**MediaTypeService** Notifications - object list -public void Handle(TemplateSavedNotification notification) -{ - var valueFromSaving = notification.State["SomeKey"]; -} -``` +The MediaTypeService class implements IMediaTypeService. It provides access to operations involving IMediaType. -### Registering notification handlers +Below you can find a list of the most common MediaTypeService object notifications. -Once you've made your notification handlers, you need to register them with the `AddNotificationHandler` extension method on the `IUmbracoBuilder`. This enables them to run whenever a notification they subscribe to is published. There are two ways to do this: +* [MediaTypeSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeSavingNotification.html) -1. In the **Startup** class, if you're making handlers for your site -2. In a [**composer**](../../implementation/composing.md), if you're a package developer subscribing to notifications +* [MediaTypeSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeSavedNotification.html) -#### Registering notification handlers in the startup class +* [MediaTypeDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeDeletingNotification.html) -In the `Program.cs` file, register your notification handler after `AddComposers()` but before `Build()`: +* [MediaTypeDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeDeletedNotification.html) -```csharp -builder.CreateUmbracoBuilder() - .AddBackOffice() - .AddWebsite() - .AddDeliveryApi() - .AddComposers() - .AddNotificationHandler() - .Build(); -``` +* [MediaTypeMovingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeMovingNotification.html) -The extension method takes two generic type parameters. The first, `ContentPublishingNotification`, is the notification you wish to subscribe to. The second, `DontShout`, is the class that handles the notification. This class must implement `INotificationHandler<>` with the type of notification it handles as the generic type parameter. In this case, the `DontShout` class definition looks like this: +* [MediaTypeMovedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeMovedNotification.html) -```csharp -public class DontShout : INotificationHandler -``` +* [MediaTypeChangedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeChangedNotification.html) -For the full handler implementation, see [ContentService Notifications](contentservice-notifications.md). +
-#### Registering notification handlers in a composer +
-If you're writing a package for Umbraco you won't have access to the Startup class. You can instead use a composer, which gives you access to the `IUmbracoBuilder`. the rest is the same as when doing it in the Startup class: +**MemberTypeService** Notifications -```csharp -public class DontShoutComposer : IComposer -{ - public void Compose(IUmbracoBuilder builder) - { - builder.AddNotificationHandler(); - } -} -``` +The MemberTypeService class implements IMemberTypeService. It provides access to operations involving IMemberType -#### Registering many notification handlers +Below you can find a list of the most common MemberTypeService object notifications. -You may want to subscribe to many notifications, meaning your `Program.cs` file or composer might become cluttered. You can avoid this by creating your own `IUmbracoBuilder` extension method for your events, keeping everything neatly wrapped up in one place, as follows: +* [MemberTypeSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeSavingNotification.html) -```csharp -using Umbraco.Cms.Core.DependencyInjection; -using Umbraco.Cms.Core.Services.Notifications; +* [MemberTypeSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeSavedNotification.html) -namespace MySite; +* [MemberTypeDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeDeletingNotification.html) -public static class UmbracoBuilderNotificationExtensions -{ - public static IUmbracoBuilder AddDontShoutNotifications(this IUmbracoBuilder builder) - { - public static IUmbracoBuilder AddDontShoutNotifications(this IUmbracoBuilder builder) - { - builder - .AddNotificationHandler() - .AddNotificationHandler() - .AddNotificationHandler(); +* [MemberTypeDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeDeletedNotification.html) - return builder; - } - } -} -``` +* [MemberTypeMovingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeMovingNotification.html) -You can then register all these notifications by calling `AddDontShoutNotifications` in the `Program.cs` file or your composer, like you would `AddNotificationHandler`: +* [MemberTypeMovedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeMovedNotification.html) -```csharp -builder.CreateUmbracoBuilder() - .AddBackOffice() - .AddWebsite() - .AddDeliveryApi() - .AddComposers() - .AddDontShoutNotifications() - .Build(); -``` +* [MemberTypeChangedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeChangedNotification.html) -Now, your handler will handle all the notifications you registered in your extension method. +
-## Async Notification Handler +
-If you need to do anything asynchronously when handling a notification, you can achieve this using the `INotificationAsyncHandler`. +**DataTypeService** Notifications -### Notification handler +The DataTypeService class implements IDataTypeService. It provides access to operations involving IDataType. -Create an asynchronous handler by implementing the `INotificationAsyncHandler`: +Below you can find a list of the most common DataTypeService object notifications. -```csharp -public class ContentDeletedHandler : INotificationAsyncHandler -{ - public async Task HandleAsync(ContentDeletedNotification notification, CancellationToken cancellationToken) - { - // await anything - await Task.Delay(1000); - } -} -``` +* [DataTypeSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeSavingNotification.html) -### Notification registration +* [DataTypeSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeSavedNotification.html) -When using the `INotificationAsyncHandler`, register it using the `IUmbracoBuilder` and the `AddNotificationAsyncHandler` extension method. This can be done in the Startup class or with a composer. +* [DataTypeDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeDeletingNotification.html) -#### Registering notification async handlers in the startup class +* [DataTypeDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeDeletedNotification.html) -Register your notification async handler to the `IUmbracoBuilder` in the Startup class: +* [DataTypeMovingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeMovingNotification.html) -```csharp -builder.CreateUmbracoBuilder() - .AddBackOffice() - .AddWebsite() - .AddDeliveryApi() - .AddComposers() - .AddNotificationAsyncHandler() - .Build(); -``` +* [DataTypeMovedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeMovedNotification.html) -#### Registering notification async handlers in a composer +
-If you do not have access to the Startup class, use a composer instead: +
-```csharp -public class NotificationHandlersComposer : IComposer -{ - public void Compose(IUmbracoBuilder builder) - { - builder.AddNotificationAsyncHandler(); - } -} -``` - -## Content, Media, and Member notifications - -* See [ContentService Notifications](contentservice-notifications.md) for a list of the ContentService object notifications. -* See [MediaService Notifications](mediaservice-notifications.md) for a list of the MediaService object notifications. -* See [MemberService Notifications](memberservice-notifications.md) for a list of the MemberService object notifications. +**FileService** Notifications -## Other notifications +The FileService class implements IFileService. It provides access to operations involving IFile objects like scripts, stylesheets and templates. -* See [ContentTypeService Notifications](contentypeservice-notifications.md) for a list of the ContentTypeService object notifications. -* See [MediaTypeService Notifications](mediatypeservice-notifications.md) for a list of the MediaTypeService object notifications. -* See [MemberTypeService Notifications](membertypeservice-notifications.md) for a list of the MemberTypeService object notifications. -* See [DataTypeService Notifications](datatypeservice-notifications.md) for a list of the DataTypeService object notifications. -* See [FileService Notifications](fileservice-notifications.md) for a list of the FileService object notifications. -* See [LocalizationService Notifications](localizationservice-notifications.md) for a list of the LocalizationService object notifications. +Below you can find a list of the most common FileService object notifications. -## Tree notifications +* [TemplateSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.TemplateSavingNotification.html) + +* [TemplateSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.TemplateSavedNotification.html) + +* [ScriptSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ScriptSavingNotification.html) + +* [ScriptSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ScriptSavedNotification.html) + +* [StylesheetSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetSavingNotification.html) + +* [StylesheetSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetSavedNotification.html) + +* [TemplateDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.TemplateDeletingNotification.html) + +* [TemplateDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.TemplateDeletedNotification.html) + +* [ScriptDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ScriptDeletingNotification.html) + +* [ScriptDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ScriptDeletedNotification.html) + +* [StylesheetDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetDeletingNotification.html) + +* [StylesheetDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetDeletedNotification.html) + +
+ +
+ +**LocalizationService** Notifications + +The LocalizationService class implements ILocalizationService. It provides access to operations involving Language and DictionaryItem. + +Below you can find a list of the most common LocalizationService object notifications. + +* [LanguageSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.LanguageSavingNotification.html) + +* [LanguageSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.LanguageSavedNotification.html) + +* [DictionaryItemSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemSavingNotification.html) + +* [DictionaryItemSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemSavedNotification.html) + +* [LanguageDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.LanguageDeletingNotification.html) + +* [LanguageDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.LanguageDeletedNotification.html) + +* [DictionaryItemDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemDeletingNotification.html) + +* [DictionaryItemDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemDeletedNotification.html) + +
+ +
+ +**CacheRefresher** Notifications + +Below you can find a list of the most common CacheRefresher object notifications. + +* [ContentCacheRefresherNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.ContentCacheRefresherNotification.html) + +* [MediaCacheRefresherNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MediaCacheRefresherNotification.html) + +* [MemberCacheRefresherNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.MemberCacheRefresherNotification.html) + +* [UserCacheRefresherNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.UserCacheRefresherNotification.html) + +
+ +
+ +**RelationService** Notifications + +Below you can find a list of the most common RelationService object notifications. + +The RelationService provides access to operations involving IRelation and IRelationType, and publishes the following relation notifications: + +* [RelationSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.RelationSavingNotification.html) + +* [RelationSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.RelationSavedNotification.html) + +* [RelationDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.RelationDeletingNotification.html) + +* [RelationDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.RelationDeletedNotification.html) + +* [RelationTypeSavingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeSavingNotification.html) + +* [RelationTypeSavedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeSavedNotification.html) + +* [RelationTypeDeletingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeDeletingNotification.html) + +* [RelationTypeDeletedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeDeletedNotification.html) + +
+ +
+ +**UmbracoApplicationLifetime** Notifications + +Represents an Umbraco application lifetime (starting, started, stopping, stopped) notification. + +Below you can find a list of the most common UmbracoApplicationLifetime object notifications. + +* [UmbracoApplicationStartingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStartingNotification.html) + +* [UmbracoApplicationStartedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStartedNotification.html) + +* [UmbracoApplicationStoppingNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStoppingNotification.html) + +* [UmbracoApplicationStoppedNotification](https://apidocs.umbraco.com/v13/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStoppedNotification.html) + +
+ +### Tree notifications See [Tree Notifications](../../extending/section-trees/) for a list of the tree notifications. -## Editor Model Notifications +### Editor Model Notifications -See [EditorModel Notifications](editormodel-notifications/) for a list of the EditorModel events +See [EditorModel Notifications](editormodel-notifications/) for a list of the EditorModel events. {% hint style="info" %} Useful for manipulating the model before it is sent to an editor in the backoffice. It could be used to set a default value of a property on a new document. @@ -204,3 +365,23 @@ Useful for manipulating the model before it is sent to an editor in the backoffi ## Creating and publishing your own custom notifications Umbraco uses notifications to allow people to hook into different workflow processes. This notification pattern is extensible, allowing you to create and publish custom notifications, and other people to observe and hook into your custom processes. This approach can be very useful when creating Umbraco packages. For more information on how you create and publish your own notifications, see the [creating and publishing notifications](creating-and-publishing-notifications.md) article. + +## Samples + +Below you can find some articles with some examples using Notifications. + +* [CacheRefresher Notification](./cacherefresher-notifications.md) + +* [ContentService Notifications](./contentservice-notifications.md) + +* [Determining if an entity is new](./determining-new-entity.md) + +* [Hot vs. cold restarts](./hot-vs-cold-restarts.md) + +* [MediaService Notifications](./mediaservice-notifications.md) + +* [MemberService Notifications](./memberservice-notifications.md) + +* [Sending Allowed Children Notification](./sendingallowedchildrennotifications.md) + +* [Umbraco Application Lifetime Notifications](./umbracoapplicationlifetime-notifications.md) diff --git a/13/umbraco-cms/reference/notifications/cacherefresher-notifications.md b/13/umbraco-cms/reference/notifications/cacherefresher-notifications.md index d36564ad6d0..da54f65f7a6 100644 --- a/13/umbraco-cms/reference/notifications/cacherefresher-notifications.md +++ b/13/umbraco-cms/reference/notifications/cacherefresher-notifications.md @@ -1,3 +1,7 @@ +--- +description: Example of how to use a CacheRefresher Notification +--- + # CacheRefresher Notifications Before starting with cache refresher notifications it's a good idea to ensure you need to use them. If you want to react to changes in content, for instance, there's no real reason to use these notifications. This is due to the [content service notifications](contentservice-notifications.md) being easier to work with. If you need to react to changes in the cache, then these are the notifications for you. @@ -105,10 +109,3 @@ public class ContentCacheRefresherExample : INotificationHandler
  • object MessageObject
  • MessageType MessageType
  • |

    Published when the content cache has been updated.
    MessageObject: The refresher payload.
    MessageType: The type of cache refresher message.

    | -| MediaCacheRefresherNotification | |

    Published when the media cache has been updated.
    MessageObject: The refresher payload.
    MessageType: The type of cache refresher message.

    | -| MemberCacheRefresherNotification | |

    Published when the member cache has been updated.
    MessageObject: The refresher payload.
    MessageType: The type of cache refresher message.

    | -| UserCacheRefresherNotification | |

    Published when the user cache has been updated.
    MessageObject: The refresher payload.
    MessageType: The type of cache refresher message.

    | diff --git a/13/umbraco-cms/reference/notifications/contentservice-notifications.md b/13/umbraco-cms/reference/notifications/contentservice-notifications.md index 71aca8fd72e..779c0cb6fc2 100644 --- a/13/umbraco-cms/reference/notifications/contentservice-notifications.md +++ b/13/umbraco-cms/reference/notifications/contentservice-notifications.md @@ -1,3 +1,7 @@ +--- +description: Find out more about ContentService Notifications and explore some example of how to use it +--- + # ContentService Notifications The ContentService class is the most commonly used type when extending Umbraco using notifications. ContentService implements IContentService. It provides access to operations involving IContent. @@ -33,35 +37,6 @@ public class DontShout : INotificationHandler } ``` -## Notifications - -| Notification | Members | Description | -| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| ContentSavingNotification |
    • IEnumerable<IContent> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when the IContentService.Save is called in the API.
    NOTE: It can be skipped if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    SavedEntities: The collection of IContent objects being saved.
    NOTE: If the entity is brand new then HasIdentity will equal false.

    | -| ContentSavedNotification |
    • IEnumerable<IContent> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when IContentService.Save is called in the API and after data has been persisted.
    NOTE: It can be skipped if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    NOTE: See here on how to determine if the entity is brand new
    SavedEntities: The saved collection of IContent objects.

    | -| ContentPublishingNotification |
    • IEnumerable<IContent> PublishedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when IContentService.Publishing is called in the API.
    NOTE: It can be skipped if the parameter "raiseEvents" is set to false during the Publish method call (true by default).
    NOTE: If the entity is brand new then HasIdentity will equal false.
    PublishedEntities: The collection of IContent objects being published.

    | -| ContentPublishedNotification |
    • IEnumerable<IContent> PublishedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when IContentService.Publish is called in the API and after data has been published.
    NOTE: It can be skipped if the parameter "raiseEvents" is set to false during the Publish method call (true by default).
    NOTE: See here on how to determine if the entity is brand new
    PublishedEntities: The published collection of IContent objects.

    | -| ContentUnpublishingNotification |
    • IEnumerable<IContent> UnpublishedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when IContentService.UnPublishing is called in the API.
    UnpublishedEntities: The collection of IContent being unpublished.

    | -| ContentUnpublishedNotification |
    • IEnumerable<IContent> UnpublishedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when IContentService.UnPublish is called in the API and after data has been unpublished.
    UnpublishedEntities: The collection of unpublished IContent.

    | -| ContentCopyingNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    • IContent Original
    • IContent Copy
    • int ParentId
    |

    Published when IContentService.Copy is called in the API.
    The notification is published after a copy object has been created and had its parentId updated and its state has been set to unpublished.

    1. Original: Gets the original IContent object.
    2. Copy: Gets the IContent object being copied.
    3. ParentId: Gets the Id of the parent of the IContent being copied.
    | -| ContentCopiedNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • IContent Original
    • IContent Copy
    • int ParentId
    • bool RelateToOriginal
    |

    Published when IContentService.Copy is called in the API.
    The notification is published after the content object has been copied.

    1. Original: Gets the original IContent object.
    2. Copy: Gets the IContent object being copied.
    3. ParentId: Gets the Id of the parent of the IContent being copied.
    4. RelateToOriginal: Boolean indicating whether the copy was related to the original
    | -| ContentMovingNotification |
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when IContentService.Move is called in the API.
    NOTE: If the target parent is the Recycle bin, this notification is never published. Try the ContentMovingToRecycleBinNotification instead.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IContent object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    | -| ContentMovedNotification |
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when IContentService.Move is called in the API. The notification is published after the content object has been moved.
    NOTE: If the target parent is the Recycle bin, this notification is never published. Try the ContentMovedToRecycleBinNotification instead.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IContent object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    | -| ContentMovingToRecycleBinNotification |
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.MoveToRecycleBin is called in the API.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IContent object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the RecycleBin
    | -| ContentMovedToRecycleBinNotification |
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.MoveToRecycleBin is called in the API. Is published after the content has been moved to the RecycleBin
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IContent object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the RecycleBin
    | -| ContentDeletingNotification |
    • IEnumerable<IContent> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.DeleteContentOfType, ContentService.Delete, ContentService.EmptyRecycleBin are called in the API.
    DeletedEntities: Gets the collection of IContent objects being deleted.

    | -| ContentDeletedNotification |
    • IEnumerable<IContent> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.Delete, ContentService.EmptyRecycleBin are called in the API, and the entity has been deleted.
    DeletedEntities: Gets the collection of deleted IContent objects.

    | -| ContentDeletingVersionsNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    • int Id
    • int SpecificVersion
    • DateTime DateToRetain
    • bool DeletePriorVersions
    |

    Published when ContentService.DeleteVersion, ContentService.DeleteVersions are called in the API.

    1. Id: Gets the id of the IContent object being deleted.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersion: Gets the id of the IContent object version being deleted.
    4. DeletePriorVersions: False by default
    | -| ContentDeletedVersionsNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • int Id
    • int SpecificVersion
    • DateTime DateToRetain
    • bool DeletePriorVersions
    |

    Published when ContentService.DeleteVersion, ContentService.DeleteVersions are called in the API, and the version has been deleted.

    1. Id: Gets the id of the IContent object being deleted.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersion: Gets the id of the IContent object version being deleted.
    4. DeletePriorVersions: False by default
    | -| ContentRollingBackNotification |
    • IContent Entity
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.Rollback is called in the API.
    Entity: Gets the IContent object being rolled back.

    | -| ContentRolledBackNotification |
    • IContent Entity
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.Rollback is called in the API, after the content has been rolled back.
    Entity: Gets the IContent object being rolled back.

    | -| ContentSendingToPublishNotification |
    • IContent Entity
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.SendToPublication is called in the API.
    Entity: Gets the IContent object being sent to publish.

    | -| ContentSentToPublishNotification |
    • IContent Entity
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.SendToPublication is called in the API, after the entity has been sent to publication.
    Entity: Gets the IContent object being sent to publish.

    | -| ContentEmptyingRecycleBinNotification |
    • IEnumerable<IContent> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.EmptyRecycleBin is called in the API.
    DeletedEntities: The collection of IContent objects being deleted.

    | -| ContentEmptiedRecycleBinNotification |
    • IEnumerable<IContent> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.EmptyRecycleBin is called in the API, after the RecycleBin has been emptied.
    DeletedEntities: The collection of deleted IContent object.

    | -| ContentSavedBlueprintNotification |
    • IContent SavedBlueprint
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.SavedBlueprint is called in the API.
    SavedBlueprint: Gets the saved blueprint IContent object

    | -| ContentDeletedBlueprintNotification |
    • IEnumerable<IContent> DeletedBlueprints
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.DeletedBlueprint is called in the API.
    DeletedBlueprints: The collection of deleted blueprint IContent

    | - ### Variants and Notifications Umbraco V8 introduced the concept of Variants for Document Types, initially to allow different language variants of particular properties within a Document Type to be edited/translated based on the languages configured in your instance of Umbraco. @@ -112,10 +87,10 @@ When handling the Unpublishing notification, it might not work how you would exp ```csharp public void Handle(ContentUnpublishingNotification notification) { - foreach (var unPublishedEntity in notification.UnpublishedEntities) - { - // complete unpublishing of entity, all cultures - } + foreach (var unPublishedEntity in notification.UnpublishedEntities) + { + // complete unpublishing of entity, all cultures + } } ``` diff --git a/13/umbraco-cms/reference/notifications/contentypeservice-notifications.md b/13/umbraco-cms/reference/notifications/contentypeservice-notifications.md deleted file mode 100644 index 0f99644ca54..00000000000 --- a/13/umbraco-cms/reference/notifications/contentypeservice-notifications.md +++ /dev/null @@ -1,134 +0,0 @@ -# ContentTypeService Notifications - -The ContentTypeService class implements IContentTypeService. It provides access to operations involving IContentType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    ContentTypeSavingNotification -
      -
    • IEnumerable<IContentType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IContentType objects being saved. -
    ContentTypeSavedNotification -
      -
    • IEnumerable<IContentType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentTypeService.Save is called in the API, after the entities has been saved.
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the collection of saved IContentType objects. -
    ContentTypeDeletingNotification -
      -
    • IEnumerable<IContentType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IContentType objects being deleted. -
    ContentTypeDeletedNotification -
      -
    • IEnumerable<IContentType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentTypeService.Delete is called in the API, after the entities has been deleted.
    - DeletedEntities: Gets the collection of deleted IContentType objects. -
    ContentTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IContentType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentTypeService.Move is called in the API
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContentType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    ContentTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IContentType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentTypeService.Move is called in the API, after the entities has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContentType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    ContentTypeChangedNotification -
      -
    • IEnumerable<ContentTypeChange<IContentType>> Changes
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when a ContentType is saved or deleted, after the transaction has completed. This is mainly used for caching purposes, and generally not recommended, use Saved and Deleted notifications instead.
    - Changes will for each item affected by the change prove: -
      -
    1. Item: The IContentType affected by the change.
    2. -
    3. ChangeTypes: The type of change: Create, Remove, RefreshMain, etc.
    4. -
    -
    diff --git a/13/umbraco-cms/reference/notifications/creating-and-publishing-notifications.md b/13/umbraco-cms/reference/notifications/creating-and-publishing-notifications.md index 040c5e5e63a..746ccd28b17 100644 --- a/13/umbraco-cms/reference/notifications/creating-and-publishing-notifications.md +++ b/13/umbraco-cms/reference/notifications/creating-and-publishing-notifications.md @@ -45,8 +45,8 @@ Now you can create a handler that receives the amount of items deleted through t Just creating the notification classes is not enough, we also want to be able to publish them. There's two ways of publishing notifications: -- `IEventAggregator` - Notifications published with `IEventAggregator` will always be published immediately. -- `IScope.Notifications` - Notifications published with a scope will only be published once the scope has been completed and disposed. +- `IEventAggregator` - Notifications published with `IEventAggregator` will always be published immediately. +- `IScope.Notifications` - Notifications published with a scope will only be published once the scope has been completed and disposed. The method you use to publish notifications depends on what your needs are, the benefits of publishing notifications with a scope is that the notification will only be published if you complete the scope, and then only once the scope is disposed of. This can be useful if you access the database, or do some other operation that might fail causing you to do a rollback, disposing of the scope without completing it, in this case, you might not want to publish a notification that signals that the operation was a success, using scopes will handle this for you. On the other hand, you might want to publish the notification immediately no matter what, for instance with the `CleanYourRoomStartedNotification`, for this, the `IEventAggregator` is the right choice. diff --git a/13/umbraco-cms/reference/notifications/datatypeservice-notifications.md b/13/umbraco-cms/reference/notifications/datatypeservice-notifications.md deleted file mode 100644 index ab374fb633a..00000000000 --- a/13/umbraco-cms/reference/notifications/datatypeservice-notifications.md +++ /dev/null @@ -1,116 +0,0 @@ -# DataTypeService Notifications - -The DataTypeService class implements IDataTypeService. It provides access to operations involving IDataType. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    DataTypeSavingNotification -
      -
    • IEnumerable<IDataType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when DataTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IDataType objects being saved. -
    DataTypeSavedNotification -
      -
    • IEnumerable<IDataType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when DataTypeService.Save is called in the API and after data has been persisted. - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the saved collection of IDataType objects. -
    DataTypeDeletingNotification -
      -
    • IEnumerable<IDataType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when DataTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IDataType objects being deleted. -
    DataTypeDeletedNotification -
      -
    • IEnumerable<IDataType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when DataTypeService.Delete is called in the API, after the IDataType objects has been deleted.
    - DeletedEntities: Gets the collection of deleted IDataType objects. -
    DataTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IDataType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when IDataTypeService.Move is called in the API.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IDataType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    DataTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IDataType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when IDataTypeService.Move is called in the API, after the IDataType has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the moved IDataType object
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    diff --git a/13/umbraco-cms/reference/notifications/determining-new-entity.md b/13/umbraco-cms/reference/notifications/determining-new-entity.md index 8d0101dd92d..8ed1b295756 100644 --- a/13/umbraco-cms/reference/notifications/determining-new-entity.md +++ b/13/umbraco-cms/reference/notifications/determining-new-entity.md @@ -1,3 +1,7 @@ +--- +description: Example of how to determine if an entity is new +--- + # Determining if an entity is new Many of the Umbraco services publishes a 'Saved' notification (or similar). In some cases, it is beneficial to know if this entity is a brand new entity that has been persisted in the database. This is how you can determine this. @@ -23,4 +27,4 @@ Since the IContent has not been saved yet, it's not necessary to cast it to `IRe ## How it works -This is all possible because of the `IRememberBeingDirty` interface. Indeed the name of this interface is hilarious but it describes exactly what it does. All entities implement this interface which is really handy. It tracks not only the property data that has changed because it inherits from yet another hilarious interface called `ICanBeDirty`. It also tracks the property data that was changed before it was committed. \ No newline at end of file +This is all possible because of the `IRememberBeingDirty` interface. Indeed the name of this interface is hilarious but it describes exactly what it does. All entities implement this interface which is really handy. It tracks not only the property data that has changed because it inherits from yet another hilarious interface called `ICanBeDirty`. It also tracks the property data that was changed before it was committed. diff --git a/13/umbraco-cms/reference/notifications/fileservice-notifications.md b/13/umbraco-cms/reference/notifications/fileservice-notifications.md deleted file mode 100644 index 1b0e46f759f..00000000000 --- a/13/umbraco-cms/reference/notifications/fileservice-notifications.md +++ /dev/null @@ -1,210 +0,0 @@ -# FileService Notifications - -The FileService class implements IFileService. It provides access to operations involving IFile objects like scripts, stylesheets and templates. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    TemplateSavingNotification -
      -
    • IEnumerable<ITemplate> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    • string ContentTypeAlias
    • -
    • bool CreateTemplateForContentType
    • -
    -
    - Published when FileService.SaveTemplate is called in the API.
    -
      -
    1. SavedEntities: Gets the collection of ITemplate objects being saved.
    2. -
    3. ContentTypeAlias: The alias of the ContentType the template is for, this is used when creating a Document Type with Template, it's not recommended to try and change or set this.
    4. -
    5. CreateTemplateForContentType: Boolean value determining if the template is create for a Document Type, it's not recommended to change this value.
    6. -
    -
    TemplateSavedNotification -
      -
    • IEnumerable<ITemplate> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • string ContentTypeAlias
    • -
    • bool CreateTemplateForContentType
    • -
    -
    - Published when FileService.SaveTemplate is called in the API, after the template has been saved.
    -
      -
    1. SavedEntities: Gets the collection of saved ITemplate objects.
    2. -
    3. ContentTypeAlias: The alias of the ContentType the template is for, this is used when creating a Document Type with Template, it's not recommended to try and change this value.
    4. -
    5. CreateTemplateForContentType: Boolean value determining if the template is create for a Document Type, it's not recommended to change this value.
    6. -
    -
    ScriptSavingNotification -
      -
    • IEnumerable<IScript> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.SaveScript is called in the API.
    - SavedEntities: Gets the collection of IScript objects being saved. -
    ScriptSavedNotification -
      -
    • IEnumerable<IScript> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.SaveScript is called in the API, after the script has been saved.
    - SavedEntities: Gets the collection of saved IScript objects. -
    StylesheetSavingNotification -
      -
    • IEnumerable<IStylesheet> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.SaveStyleSheet is called in the API.
    - SavedEntities: Gets the collection of IStylesheet objects being saved. -
    StylesheetSavedNotification -
      -
    • IEnumerable<IStylesheet> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.SaveStylesheet is called in the API, after the script has been saved.
    - SavedEntities: Gets the collection of saved IStylesheet objects. -
    TemplateDeletingNotification -
      -
    • IEnumerable<ITemplate> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.DeleteTemplate is called in the API.
    - DeletedEntities: Gets the collection of ITemplate objects being deleted. -
    TemplateDeletedNotification -
      -
    • IEnumerable<ITemplate> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.DeleteTemplate is called in the API, after the template has been deleted.
    - DeletedEntities: Gets the collection of deleted ITemplate objects. -
    ScriptDeletingNotification -
      -
    • IEnumerable<IScript> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.DeleteScript is called in the API.
    - DeletedEntities: Gets the collection of IScript objects being deleted. -
    ScriptDeletedNotification -
      -
    • IEnumerable<IScript> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.DeleteScript is called in the API, after the script has been deleted.
    - DeletedEntities: Gets the collection of deleted IScript objects. -
    StylesheetDeletingNotification -
      -
    • IEnumerable<IStylesheet> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.DeleteStylesheet is called in the API.
    - DeletedEntities: Gets the collection of IStylesheet objects being deleted. -
    StylesheetDeletedNotification -
      -
    • IEnumerable<IStylesheet> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.DeleteStylesheet is called in the API, after the stylesheet has been deleted.
    - DeletedEntities: Gets the collection of deleted IStylesheet objects. -
    \ No newline at end of file diff --git a/13/umbraco-cms/reference/notifications/hot-vs-cold-restarts.md b/13/umbraco-cms/reference/notifications/hot-vs-cold-restarts.md index 3d23d4a6b5a..7f30c314565 100644 --- a/13/umbraco-cms/reference/notifications/hot-vs-cold-restarts.md +++ b/13/umbraco-cms/reference/notifications/hot-vs-cold-restarts.md @@ -29,7 +29,7 @@ Below is a list of some of the more common reasons: ## In Memory Auto -Another factor that can slow down time to first page load is the [In Memory Auto models builder](../templating/modelsbuilder/builder-modes.md#in-memory) setting. Having this setting enabled will result in the first page load being slower. The reason for this is that when the first page is requested, the strongly typed models needs to be compiled and loaded in. +Another factor that can slow down time to first page load is the [In Memory Auto models builder](../templating/modelsbuilder/builder-modes.md#in-memory) setting. Having this setting enabled will result in the first page load being slower. The reason for this is that when the first page is requested, the strongly typed models needs to be compiled and loaded in. This is, however, less noticeable on consecutive restarts, a bit like hot and cold restarts. Since the compiled models will be cached on disk, they don't need to be recompiled until the models change again. diff --git a/13/umbraco-cms/reference/notifications/localizationservice-notifications.md b/13/umbraco-cms/reference/notifications/localizationservice-notifications.md deleted file mode 100644 index 0d9767af0a3..00000000000 --- a/13/umbraco-cms/reference/notifications/localizationservice-notifications.md +++ /dev/null @@ -1,135 +0,0 @@ -# LocalizationService Events - -The LocalizationService class implements ILocalizationService. It provides access to operations involving Language and DictionaryItem. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    LanguageSavingNotification -
      -
    • IEnumerable<ILanguage> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Save (ILanguage overload) is called in the API.
    - SavedEntities: Gets the collection of ILanguage objects being saved. -
    LanguageSavedNotification -
      -
    • IEnumerable<ILanguage> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - RPublished when LocalizationService.Save (ILanguage overload) is called in the API after data has been persisted.
    - SavedEntities: Gets the saved collection of ILanguage objects.. -
    DictionaryItemSavingNotification -
      -
    • IEnumerable<IDictionaryItem> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Save (IDictionaryItem overload) is called in the API.
    - SavedEntities: Gets the collection of IDictionaryItem objects being saved. -
    DictionaryItemSavedNotification -
      -
    • IEnumerable<IDictionaryItem> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when LocalizationService.Save (IDictionaryItem overload) is called in the API and the data has been persisted.
    - SavedEntities: Gets the saved collection of IDictionary objects. -
    LanguageDeletingNotification -
      -
    • IEnumerable<ILanguage> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Delete (ILanguage overload) is called in the API.
    - DeletedEntities: Gets the collection of ILanguage objects being deleted. -
    LanguageDeletedNotification -
      -
    • IEnumerable<ILanguage> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when LocalizationService.Delete (ILanguage overload) is called in the API, after the languages has been deleted.
    - DeletedEntities: Gets the collection of deleted ILanguage objects. -
    DictionaryItemDeletingNotification -
      -
    • IEnumerable<IDictionaryItem> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Delete (IDictionaryItem overload) is called in the API.
    - DeletedEntities: Gets the collection of IDictionaryItem objects being deleted -
    DictionaryItemDeletedNotification -
      -
    • IEnumerable<IDictionaryItem> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when LocalizationService.Delete (IDictionaryItem overload) is called in the API, after the dictionary items has been deleted.
    - DeletedEntities: Gets the collection of deleted IDictionaryItem objects. -
    \ No newline at end of file diff --git a/13/umbraco-cms/reference/notifications/mediaservice-notifications.md b/13/umbraco-cms/reference/notifications/mediaservice-notifications.md index 2263eeb8eb6..050e0b90027 100644 --- a/13/umbraco-cms/reference/notifications/mediaservice-notifications.md +++ b/13/umbraco-cms/reference/notifications/mediaservice-notifications.md @@ -1,3 +1,7 @@ +--- +description: Example of how to use a MediaService Notification +--- + # MediaService Notifications The MediaService class implements IMediaService. It provides access to operations involving IMedia. @@ -76,21 +80,6 @@ namespace MyProject ![image](https://github.com/umbraco/UmbracoDocs/assets/6904597/67696298-2710-4aeb-bd0a-33c6d8414216) -## Events - -| Notification | Members | Description | -| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| MediaSavingNotification |
    • IEnumerable<IMedia> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MediaService.Save is called in the API.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    SavedEntities: Gets the collection of IMedia objects being saved.

    | -| MediaSavedNotification |
    • IEnumerable<IMedia> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MediaService.Save is called in the API and after the data has been persisted.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    SavedEntities: Gets the saved collection of IMedia objects.

    | -| MediaMovingNotification |
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MediaService.Move is called in the API.
    NOTE: If the target parent is the Recycle bin, this notification is never published. Try the MediaMovingToRecycleBinNotification instead.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IMedia object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    | -| MediaMovedNotification |
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MediaService.Move is called in the API. The event is fired after the media object has been moved.
    NOTE: If the target parent is the Recycle bin, this notification is never published. Try the MediaMovedToRecycleBinNotification instead.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IMedia object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    | -| MediaMovingToRecycleBinNotification |
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MediaService.MoveToRecycleBin is called in the API.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IMedia object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the RecycleBin
    | -| MediaMovedToRecycleBinNotification |
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MediaService.MoveToRecycleBin is called in the API, after the media object has been moved to the RecycleBin.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IMedia object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the RecycleBin
    | -| MediaDeletingNotification |
    • IEnumerable<IMedia> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MediaService.DeleteMediaOfType, MediaService.Delete, MediaService.EmptyRecycleBin are called in the API.
    DeletedEntities: Gets the collection of IMedia objects being deleted.

    | -| MediaDeletedNotification |
    • IEnumerable<IMedia> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MediaService.Delete, MediaService.EmptyRecycleBin are called in the API, after the media has been deleted.
    DeletedEntities: Gets the collection of deleted IMedia objects.

    | -| MediaDeletingVersionsNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    • int Id
    • int SpecificVersion
    • DateTime DateToRetain
    • bool DeletePriorVersions
    |

    Published when MediaService.DeleteVersion, MediaService.DeleteVersions are called in the API.

    1. Id: Gets the id of the IMedia object being deleted.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersion: Gets the id of the IMedia object version being deleted.
    4. DeletePriorVersions: False by default
    | -| MediaDeletedVersionsNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • int Id
    • int SpecificVersion
    • DateTime DateToRetain
    • bool DeletePriorVersions
    |

    Published when MediaService.DeleteVersion, MediaService.DeleteVersions are called in the API, after the media version has been deleted

    1. Id: Gets the id of the deleted IMedia object.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersion: Gets the id of the deleted IMedia object version.
    4. DeletePriorVersions: False by default
    | - ### What happened to Creating and Created events? Both the MediaService.Creating and MediaService.Created events have been obsoleted. Because of this, these were not moved over to notifications, and no longer exist. Why? Because these events were not guaranteed to trigger and therefore should not have been used. This is because these events _only_ triggered when the MediaService.CreateMedia method was used which is an entirely optional way to create media entities. It is also possible to construct a new media item - which is generally the preferred and consistent way - and therefore the Creating/Created events would not execute when constructing media that way. diff --git a/13/umbraco-cms/reference/notifications/mediatypeservice-notifications.md b/13/umbraco-cms/reference/notifications/mediatypeservice-notifications.md deleted file mode 100644 index c09e1392348..00000000000 --- a/13/umbraco-cms/reference/notifications/mediatypeservice-notifications.md +++ /dev/null @@ -1,134 +0,0 @@ -# MediaTypeService Notifications - -The MediaTypeService class implements IMediaTypeService. It provides access to operations involving IMediaType. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    MediaTypeSavingNotification -
      -
    • IEnumerable<IMediaType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IMediaType objects being saved. -
    MediaTypeSavedNotification -
      -
    • IEnumerable<IMediaType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaTypeService.Save is called in the API, after the entities has been saved.
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the collection of saved IMediaType objects. -
    MediaTypeDeletingNotification -
      -
    • IEnumerable<IMediaType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IMediaType objects being deleted. -
    MediaTypeDeletedNotification -
      -
    • IEnumerable<IMediaType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaTypeService.Delete is called in the API, after the entities has been deleted.
    - DeletedEntities: Gets the collection of deleted IMediaType objects. -
    MediaTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IMediaType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaTypeService.Move is called in the API
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMediaType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MediaTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IMediaType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaTypeService.Move is called in the API, after the entities has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMediaType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MediaTypeChangedNotification -
      -
    • IEnumerable<MediaTypeChange<IMediaType>> Changes
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when a MediaType is saved or deleted, after the transaction has completed. This is mainly used for caching purposes, and generally not recommended, use Saved and Deleted notifications instead.
    - Changes will for each item affected by the change prove: -
      -
    1. Item: The IMediaType affected by the change.
    2. -
    3. ChangeTypes: The type of change: Create, Remove, RefreshMain, etc.
    4. -
    -
    diff --git a/13/umbraco-cms/reference/notifications/memberservice-notifications.md b/13/umbraco-cms/reference/notifications/memberservice-notifications.md index 2469800436d..1f5df2d9069 100644 --- a/13/umbraco-cms/reference/notifications/memberservice-notifications.md +++ b/13/umbraco-cms/reference/notifications/memberservice-notifications.md @@ -1,3 +1,7 @@ +--- +description: Example of how to use a MemberService Notification +--- + # MemberService Notifications The MemberService implements IMemberService and provides access to operations involving IMember. @@ -7,7 +11,7 @@ The MemberService implements IMemberService and provides access to operations in ```csharp using Microsoft.Extensions.Logging; using Umbraco.Cms.Core.Events; -using Umbraco.Cms.Core.Services.Notifications; +using Umbraco.Cms.Core.Notifications; namespace MySite; @@ -30,12 +34,3 @@ public class MemberNotificationHandler : INotificationHandler
  • IEnumerable<IMember> SavedEntities
  • EventMessages Messages
  • IDictionary<string,object> State
  • bool Cancel
  • |

    Published when MemberService.Saving is called in the API.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    SavedEntities: Gets the collection of IMember objects being saved.

    | -| MemberSavedNotification |
    • IEnumerable<IMember> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MemberService.Save is called in the API and after data has been persisted.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    NOTE: See here on how to determine if the entity is brand new
    SavedEntities: Gets the saved collection of IMember objects.

    | -| MemberDeletingNotification |
    • IEnumerable<IMember> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MemberService.Delete, and MemberService.DeleteMembersOfType are called in the API.
    DeletedEntities: Gets the collection of IMember objects being deleted.

    | -| MemberDeletedNotification |
    • IEnumerable<IMember> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MemberService.Delete, and MemberService.DeleteMembersOfType are called in the API, after the members has been deleted.
    DeletedEntities: Gets the collection of deleted IMember objects.

    | -| AssignedMemberRolesNotification |
    • string[] Roles
    • int[] MemberIds
    |

    Published when MemberService.AssignRoles, and MemberService.ReplaceRoles are called in the API.

    1. Roles: Collection of role names being assigned.
    2. MemberIds: Collection of Ids of the members the roles are being assigned to.
    | -| RemovedMemberRolesNotification |
    • string[] Roles
    • int[] MemberIds
    |

    Published when MemberService.DissociateRoles are being called in the API.

    1. Roles: Collection of role names being removed.
    2. MemberIds: Collection of Ids of the members the roles are being removed from.
    | diff --git a/13/umbraco-cms/reference/notifications/membertypeservice-notifications.md b/13/umbraco-cms/reference/notifications/membertypeservice-notifications.md deleted file mode 100644 index e2ed4dd6089..00000000000 --- a/13/umbraco-cms/reference/notifications/membertypeservice-notifications.md +++ /dev/null @@ -1,134 +0,0 @@ -# MemberTypeService Notifications - -The MemberTypeService class implements IMemberTypeService. It provides access to operations involving IMemberType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    MemberTypeSavingNotification -
      -
    • IEnumerable<IMemberType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IMemberType objects being saved. -
    MemberTypeSavedNotification -
      -
    • IEnumerable<IMemberType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberTypeService.Save is called in the API, after the entities has been saved.
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the collection of saved IMemberType objects. -
    MemberTypeDeletingNotification -
      -
    • IEnumerable<IMemberType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IMemberType objects being deleted. -
    MemberTypeDeletedNotification -
      -
    • IEnumerable<IMemberType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberTypeService.Delete is called in the API, after the entities has been deleted.
    - DeletedEntities: Gets the collection of deleted IMemberType objects. -
    MemberTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IMemberType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberTypeService.Move is called in the API
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMemberType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MemberTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IMemberType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberTypeService.Move is called in the API, after the entities has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMemberType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MemberTypeChangedNotification -
      -
    • IEnumerable<MemberTypeChange<IMemberType>> Changes
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when a MemberType is saved or deleted, after the transaction has completed. This is mainly used for caching purposes, and generally not recommended, use Saved and Deleted notifications instead.
    - Changes will for each item affected by the change prove: -
      -
    1. Item: The IMemberType affected by the change.
    2. -
    3. ChangeTypes: The type of change: Create, Remove, RefreshMain, etc.
    4. -
    -
    diff --git a/13/umbraco-cms/reference/notifications/notification-handler.md b/13/umbraco-cms/reference/notifications/notification-handler.md new file mode 100644 index 00000000000..f795d4732ca --- /dev/null +++ b/13/umbraco-cms/reference/notifications/notification-handler.md @@ -0,0 +1,167 @@ +--- +description: Learn about notification handlers lifetime, async notification handler and how to register the notification handlers. +--- + +# Notification handlers lifetime + +It's important to know that the handlers you create and register to receive notifications will be **transient**. This means that they will be initialized every time they receive a notification. You can therefore not rely on them having a specific state based on previous notifications. + +As an example, you cannot do the following: + +1. Create a list in a handler. +2. Add something when a notification is received. +3. Check if that list contains what you added in an earlier notification. + +When following the steps above, the list will always be empty because the object has only been initialized. + +If you need persistence between notifications, we recommend you move that functionality into a service or similar. You can then register it with the DI container, and inject it into your handler. + +As previously mentioned, many notifications exist in pairs, with a "before" and "after" notification. There may be cases where you want to add some information to the "before" notification, which will then be available to your "after" notification handler. In order to support this, the notification "pairs" are **stateful**. This means the notifications contain a dictionary that is shared between the "before" and "after" notifications. You can add values to the dictionary, and later retrieve them like this: + +```csharp +public void Handle(TemplateSavingNotification notification) +{ + notification.State["SomeKey"] = "Some Value Relevant to the \"after\" notification handler"; +} + + +public void Handle(TemplateSavedNotification notification) +{ + var valueFromSaving = notification.State["SomeKey"]; +} +``` + +# Registering notification handlers + +Once you've made your notification handlers, you need to register them with the `AddNotificationHandler` extension method on the `IUmbracoBuilder`. This enables them to run whenever a notification they subscribe to is published. There are two ways to do this: + +1. In the **Program** class, if you're making handlers for your site +2. In a [**composer**](../../implementation/composing.md), if you're a package developer subscribing to notifications + +## Registering notification handlers in the program class + +In the `Program.cs` file, register your notification handler after `AddComposers()` but before `Build()`: + +```csharp +builder.CreateUmbracoBuilder() + .AddBackOffice() + .AddWebsite() + .AddDeliveryApi() + .AddComposers() + .AddNotificationHandler() + .Build(); +``` + +The extension method takes two generic type parameters. The first, `ContentPublishingNotification`, is the notification you wish to subscribe to. The second, `DontShout`, is the class that handles the notification. This class must implement `INotificationHandler<>` with the type of notification it handles as the generic type parameter. In this case, the `DontShout` class definition looks like this: + +```csharp +public class DontShout : INotificationHandler +``` + +For the full handler implementation, see [ContentService Notifications](contentservice-notifications.md). + +## Registering notification handlers in a composer + +If you're writing a package for Umbraco you won't have access to the Program class. You can instead use a composer, which gives you access to the `IUmbracoBuilder`.The rest is the same as when doing it in the Program class: + +```csharp +public class DontShoutComposer : IComposer +{ + public void Compose(IUmbracoBuilder builder) + { + builder.AddNotificationHandler(); + } +} +``` + +## Registering many notification handlers + +You may want to subscribe to many notifications, meaning your `Program.cs` file or composer might become cluttered. You can avoid this by creating your own `IUmbracoBuilder` extension method for your events, keeping everything neatly wrapped up in one place, as follows: + +```csharp +using Umbraco.Cms.Core.DependencyInjection; +using Umbraco.Cms.Core.Services.Notifications; + +namespace MySite; + +public static class UmbracoBuilderNotificationExtensions +{ + public static IUmbracoBuilder AddDontShoutNotifications(this IUmbracoBuilder builder) + { + public static IUmbracoBuilder AddDontShoutNotifications(this IUmbracoBuilder builder) + { + builder + .AddNotificationHandler() + .AddNotificationHandler() + .AddNotificationHandler(); + + return builder; + } + } +} +``` + +You can then register all these notifications by calling `AddDontShoutNotifications` in the `Program.cs` file or your composer, like you would `AddNotificationHandler`: + +```csharp +builder.CreateUmbracoBuilder() + .AddBackOffice() + .AddWebsite() + .AddDeliveryApi() + .AddComposers() + .AddDontShoutNotifications() + .Build(); +``` + +Now, your handler will handle all the notifications you registered in your extension method. + +# Async Notification Handler + +If you need to do anything asynchronously when handling a notification, you can achieve this using the `INotificationAsyncHandler`. + +## Notification handler + +Create an asynchronous handler by implementing the `INotificationAsyncHandler`: + +```csharp +public class ContentDeletedHandler : INotificationAsyncHandler +{ + public async Task HandleAsync(ContentDeletedNotification notification, CancellationToken cancellationToken) + { + // await anything + await Task.Delay(1000); + } +} +``` + +## Notification registration + +When using the `INotificationAsyncHandler`, register it using the `IUmbracoBuilder` and the `AddNotificationAsyncHandler` extension method. This can be done in the Program class or with a composer. + +### Registering notification async handlers in the program class + +Register your notification async handler to the `IUmbracoBuilder` in the Program class: + +```csharp +builder.CreateUmbracoBuilder() + .AddBackOffice() + .AddWebsite() + .AddDeliveryApi() + .AddComposers() + .AddNotificationAsyncHandler() + .Build(); +``` + +### Registering notification async handlers in a composer + +If you do not have access to the Program class, use a composer instead: + +```csharp +public class NotificationHandlersComposer : IComposer +{ + public void Compose(IUmbracoBuilder builder) + { + builder.AddNotificationAsyncHandler(); + } +} +``` diff --git a/13/umbraco-cms/reference/notifications/relationservice-notifications.md b/13/umbraco-cms/reference/notifications/relationservice-notifications.md deleted file mode 100644 index 51bfbaa80ad..00000000000 --- a/13/umbraco-cms/reference/notifications/relationservice-notifications.md +++ /dev/null @@ -1,141 +0,0 @@ -# RelationService notifications - -The RelationService provides access to operations involving `IRelation` and `IRelationType`, and published the following relation notifications: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    RelationSavingNotification -
      -
    • IEnumerable<IRelation> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation is being saved.
    - SavedEntities: The collection of IRelation objects being saved.
    -
    RelationSavedNotification -
      -
    • IEnumerable<IRelation> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation has been saved.
    - SavedEntities: The collection of IRelation objects having been saved.
    -
    RelationDeletingNotification -
      -
    • IEnumerable<IRelation> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation is being deleted.
    - SavedEntities: The collection of IRelation objects being deleted.
    -
    RelationDeletedNotification -
      -
    • IEnumerable<IRelation> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation has been deleted.
    - SavedEntities: The collection of IRelation objects having been deleted.
    -
    RelationTypeSavingNotification -
      -
    • IEnumerable<IRelationType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type being saved.
    - SavedEntities: The collection of IRelationType objects being saved.
    -
    RelationTypeSavedNotification -
      -
    • IEnumerable<IRelationType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type has been saved.
    - SavedEntities: The collection of IRelationType objects having been saved.
    -
    RelationTypeDeletingNotification -
      -
    • IEnumerable<IRelationType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type is being deleted.
    - SavedEntities: The collection of IRelationType objects being deleted.
    -
    RelationTypeDeletedNotification -
      -
    • IEnumerable<IRelationType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type has been deleted.
    - SavedEntities: The collection of IRelationType objects having been deleted.
    -
    diff --git a/13/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md b/13/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md index 1b15d758778..b3a7a9d877e 100644 --- a/13/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md +++ b/13/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md @@ -1,3 +1,7 @@ +--- +description: Example of how to use a SendingAllowedChildren Notification +--- + # Sending Allowed Children Notification The `SendingAllowedChildrenNotification` enables you to manipulate the Document Types that will be shown in the create menu when adding new content in the backoffice. diff --git a/13/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md b/13/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md index fbe3360f489..c1b26bcff5f 100644 --- a/13/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md +++ b/13/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md @@ -49,12 +49,3 @@ public class UmbracoApplicationNotificationHandler : INotificationHandler _logger.LogInformation("{Type} - {IsRestarting}", notification.GetType().Name, isRestarting); } ``` - -## Notifications - -| Notification | Members | Description | -| -------------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| UmbracoApplicationStartingNotification |
    • RuntimeLevel RuntimeLevel
    • bool IsRestarting
    |

    Triggered when the application is starting after all IComponents are initialized but before any incoming requests are accepted.

    1. RuntimeLevel: Gets the runtime level.
    2. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    | -| UmbracoApplicationStartedNotification |
    • bool IsRestarting
    |

    Triggered when the application has fully started and is accepting incoming requests.

    1. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    | -| UmbracoApplicationStoppingNotification |
    • bool IsRestarting
    |

    Triggered when the application is performing a graceful shutdown after all IComponents are terminated.

    1. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    | -| UmbracoApplicationStoppedNotification |
    • bool IsRestarting
    |

    Triggered when the application has performed a graceful shutdown.

    1. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    | From 508b41aa288a00110f60cfb2745a6aa3837dff94 Mon Sep 17 00:00:00 2001 From: "Alina-Magdalena Tincas (Umbraco HQ)" Date: Wed, 10 Apr 2024 16:00:27 +0200 Subject: [PATCH 2/5] removing the articles for v10 and v12 --- .../contentypeservice-notifications.md | 139 ----------- .../datatypeservice-notifications.md | 121 ---------- .../fileservice-notifications.md | 215 ------------------ .../localizationservice-notifications.md | 140 ------------ .../mediatypeservice-notifications.md | 139 ----------- .../membertypeservice-notifications.md | 139 ----------- .../relationservice-notifications.md | 141 ------------ .../contentypeservice-notifications.md | 134 ----------- .../datatypeservice-notifications.md | 116 ---------- .../fileservice-notifications.md | 210 ----------------- .../localizationservice-notifications.md | 135 ----------- .../mediatypeservice-notifications.md | 134 ----------- .../membertypeservice-notifications.md | 134 ----------- .../relationservice-notifications.md | 141 ------------ 14 files changed, 2038 deletions(-) delete mode 100644 10/umbraco-cms/reference/notifications/contentypeservice-notifications.md delete mode 100644 10/umbraco-cms/reference/notifications/datatypeservice-notifications.md delete mode 100644 10/umbraco-cms/reference/notifications/fileservice-notifications.md delete mode 100644 10/umbraco-cms/reference/notifications/localizationservice-notifications.md delete mode 100644 10/umbraco-cms/reference/notifications/mediatypeservice-notifications.md delete mode 100644 10/umbraco-cms/reference/notifications/membertypeservice-notifications.md delete mode 100644 10/umbraco-cms/reference/notifications/relationservice-notifications.md delete mode 100644 12/umbraco-cms/reference/notifications/contentypeservice-notifications.md delete mode 100644 12/umbraco-cms/reference/notifications/datatypeservice-notifications.md delete mode 100644 12/umbraco-cms/reference/notifications/fileservice-notifications.md delete mode 100644 12/umbraco-cms/reference/notifications/localizationservice-notifications.md delete mode 100644 12/umbraco-cms/reference/notifications/mediatypeservice-notifications.md delete mode 100644 12/umbraco-cms/reference/notifications/membertypeservice-notifications.md delete mode 100644 12/umbraco-cms/reference/notifications/relationservice-notifications.md diff --git a/10/umbraco-cms/reference/notifications/contentypeservice-notifications.md b/10/umbraco-cms/reference/notifications/contentypeservice-notifications.md deleted file mode 100644 index a4cfaaaa127..00000000000 --- a/10/umbraco-cms/reference/notifications/contentypeservice-notifications.md +++ /dev/null @@ -1,139 +0,0 @@ ---- - - ---- - -# ContentTypeService Notifications - -The ContentTypeService class implements IContentTypeService. It provides access to operations involving IContentType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    ContentTypeSavingNotification -
      -
    • IEnumerable<IContentType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IContentType objects being saved. -
    ContentTypeSavedNotification -
      -
    • IEnumerable<IContentType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentTypeService.Save is called in the API, after the entities has been saved.
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the collection of saved IContentType objects. -
    ContentTypeDeletingNotification -
      -
    • IEnumerable<IContentType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IContentType objects being deleted. -
    ContentTypeDeletedNotification -
      -
    • IEnumerable<IContentType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentTypeService.Delete is called in the API, after the entities has been deleted.
    - DeletedEntities: Gets the collection of deleted IContentType objects. -
    ContentTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IContentType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentTypeService.Move is called in the API
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContentType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    ContentTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IContentType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentTypeService.Move is called in the API, after the entities has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContentType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    ContentTypeChangedNotification -
      -
    • IEnumerable<ContentTypeChange<IContentType>> Changes
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when a ContentType is saved or deleted, after the transaction has completed. This is mainly used for caching purposes, and generally not recommended, use Saved and Deleted notifications instead.
    - Changes will for each item affected by the change prove: -
      -
    1. Item: The IContentType affected by the change.
    2. -
    3. ChangeTypes: The type of change: Create, Remove, RefreshMain, etc.
    4. -
    -
    diff --git a/10/umbraco-cms/reference/notifications/datatypeservice-notifications.md b/10/umbraco-cms/reference/notifications/datatypeservice-notifications.md deleted file mode 100644 index e0bfa8e9bf8..00000000000 --- a/10/umbraco-cms/reference/notifications/datatypeservice-notifications.md +++ /dev/null @@ -1,121 +0,0 @@ ---- - - ---- - -# DataTypeService Notifications - -The DataTypeService class implements IDataTypeService. It provides access to operations involving IDataType. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    DataTypeSavingNotification -
      -
    • IEnumerable<IDataType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when DataTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IDataType objects being saved. -
    DataTypeSavedNotification -
      -
    • IEnumerable<IDataType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when DataTypeService.Save is called in the API and after data has been persisted. - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the saved collection of IDataType objects. -
    DataTypeDeletingNotification -
      -
    • IEnumerable<IDataType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when DataTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IDataType objects being deleted. -
    DataTypeDeletedNotification -
      -
    • IEnumerable<IDataType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when DataTypeService.Delete is called in the API, after the IDataType objects has been deleted.
    - DeletedEntities: Gets the collection of deleted IDataType objects. -
    DataTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IDataType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when IDataTypeService.Move is called in the API.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IDataType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    DataTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IDataType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when IDataTypeService.Move is called in the API, after the IDataType has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the moved IDataType object
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    diff --git a/10/umbraco-cms/reference/notifications/fileservice-notifications.md b/10/umbraco-cms/reference/notifications/fileservice-notifications.md deleted file mode 100644 index 5e808b2c852..00000000000 --- a/10/umbraco-cms/reference/notifications/fileservice-notifications.md +++ /dev/null @@ -1,215 +0,0 @@ ---- - - ---- - -# FileService Notifications - -The FileService class implements IFileService. It provides access to operations involving IFile objects like scripts, stylesheets and templates. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    TemplateSavingNotification -
      -
    • IEnumerable<ITemplate> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    • string ContentTypeAlias
    • -
    • bool CreateTemplateForContentType
    • -
    -
    - Published when FileService.SaveTemplate is called in the API.
    -
      -
    1. SavedEntities: Gets the collection of ITemplate objects being saved.
    2. -
    3. ContentTypeAlias: The alias of the ContentType the template is for, this is used when creating a Document Type with Template, it's not recommended to try and change or set this.
    4. -
    5. CreateTemplateForContentType: Boolean value determining if the template is create for a Document Type, it's not recommended to change this value.
    6. -
    -
    TemplateSavedNotification -
      -
    • IEnumerable<ITemplate> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • string ContentTypeAlias
    • -
    • bool CreateTemplateForContentType
    • -
    -
    - Published when FileService.SaveTemplate is called in the API, after the template has been saved.
    -
      -
    1. SavedEntities: Gets the collection of saved ITemplate objects.
    2. -
    3. ContentTypeAlias: The alias of the ContentType the template is for, this is used when creating a Document Type with Template, it's not recommended to try and change this value.
    4. -
    5. CreateTemplateForContentType: Boolean value determining if the template is create for a Document Type, it's not recommended to change this value.
    6. -
    -
    ScriptSavingNotification -
      -
    • IEnumerable<IScript> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.SaveScript is called in the API.
    - SavedEntities: Gets the collection of IScript objects being saved. -
    ScriptSavedNotification -
      -
    • IEnumerable<IScript> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.SaveScript is called in the API, after the script has been saved.
    - SavedEntities: Gets the collection of saved IScript objects. -
    StylesheetSavingNotification -
      -
    • IEnumerable<IStylesheet> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.SaveStyleSheet is called in the API.
    - SavedEntities: Gets the collection of IStylesheet objects being saved. -
    StylesheetSavedNotification -
      -
    • IEnumerable<IStylesheet> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.SaveStylesheet is called in the API, after the script has been saved.
    - SavedEntities: Gets the collection of saved IStylesheet objects. -
    TemplateDeletingNotification -
      -
    • IEnumerable<ITemplate> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.DeleteTemplate is called in the API.
    - DeletedEntities: Gets the collection of ITemplate objects being deleted. -
    TemplateDeletedNotification -
      -
    • IEnumerable<ITemplate> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.DeleteTemplate is called in the API, after the template has been deleted.
    - DeletedEntities: Gets the collection of deleted ITemplate objects. -
    ScriptDeletingNotification -
      -
    • IEnumerable<IScript> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.DeleteScript is called in the API.
    - DeletedEntities: Gets the collection of IScript objects being deleted. -
    ScriptDeletedNotification -
      -
    • IEnumerable<IScript> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.DeleteScript is called in the API, after the script has been deleted.
    - DeletedEntities: Gets the collection of deleted IScript objects. -
    StylesheetDeletingNotification -
      -
    • IEnumerable<IStylesheet> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.DeleteStylesheet is called in the API.
    - DeletedEntities: Gets the collection of IStylesheet objects being deleted. -
    StylesheetDeletedNotification -
      -
    • IEnumerable<IStylesheet> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.DeleteStylesheet is called in the API, after the stylesheet has been deleted.
    - DeletedEntities: Gets the collection of deleted IStylesheet objects. -
    \ No newline at end of file diff --git a/10/umbraco-cms/reference/notifications/localizationservice-notifications.md b/10/umbraco-cms/reference/notifications/localizationservice-notifications.md deleted file mode 100644 index 996c7cb389d..00000000000 --- a/10/umbraco-cms/reference/notifications/localizationservice-notifications.md +++ /dev/null @@ -1,140 +0,0 @@ ---- - - ---- - -# LocalizationService Events - -The LocalizationService class implements ILocalizationService. It provides access to operations involving Language and DictionaryItem. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    LanguageSavingNotification -
      -
    • IEnumerable<ILanguage> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Save (ILanguage overload) is called in the API.
    - SavedEntities: Gets the collection of ILanguage objects being saved. -
    LanguageSavedNotification -
      -
    • IEnumerable<ILanguage> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - RPublished when LocalizationService.Save (ILanguage overload) is called in the API after data has been persisted.
    - SavedEntities: Gets the saved collection of ILanguage objects.. -
    DictionaryItemSavingNotification -
      -
    • IEnumerable<IDictionaryItem> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Save (IDictionaryItem overload) is called in the API.
    - SavedEntities: Gets the collection of IDictionaryItem objects being saved. -
    DictionaryItemSavedNotification -
      -
    • IEnumerable<IDictionaryItem> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when LocalizationService.Save (IDictionaryItem overload) is called in the API and the data has been persisted.
    - SavedEntities: Gets the saved collection of IDictionary objects. -
    LanguageDeletingNotification -
      -
    • IEnumerable<ILanguage> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Delete (ILanguage overload) is called in the API.
    - DeletedEntities: Gets the collection of ILanguage objects being deleted. -
    LanguageDeletedNotification -
      -
    • IEnumerable<ILanguage> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when LocalizationService.Delete (ILanguage overload) is called in the API, after the languages has been deleted.
    - DeletedEntities: Gets the collection of deleted ILanguage objects. -
    DictionaryItemDeletingNotification -
      -
    • IEnumerable<IDictionaryItem> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Delete (IDictionaryItem overload) is called in the API.
    - DeletedEntities: Gets the collection of IDictionaryItem objects being deleted -
    DictionaryItemDeletedNotification -
      -
    • IEnumerable<IDictionaryItem> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when LocalizationService.Delete (IDictionaryItem overload) is called in the API, after the dictionary items has been deleted.
    - DeletedEntities: Gets the collection of deleted IDictionaryItem objects. -
    \ No newline at end of file diff --git a/10/umbraco-cms/reference/notifications/mediatypeservice-notifications.md b/10/umbraco-cms/reference/notifications/mediatypeservice-notifications.md deleted file mode 100644 index 08deb834066..00000000000 --- a/10/umbraco-cms/reference/notifications/mediatypeservice-notifications.md +++ /dev/null @@ -1,139 +0,0 @@ ---- - - ---- - -# MediaTypeService Notifications - -The MediaTypeService class implements IMediaTypeService. It provides access to operations involving IMediaType. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    MediaTypeSavingNotification -
      -
    • IEnumerable<IMediaType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IMediaType objects being saved. -
    MediaTypeSavedNotification -
      -
    • IEnumerable<IMediaType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaTypeService.Save is called in the API, after the entities has been saved.
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the collection of saved IMediaType objects. -
    MediaTypeDeletingNotification -
      -
    • IEnumerable<IMediaType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IMediaType objects being deleted. -
    MediaTypeDeletedNotification -
      -
    • IEnumerable<IMediaType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaTypeService.Delete is called in the API, after the entities has been deleted.
    - DeletedEntities: Gets the collection of deleted IMediaType objects. -
    MediaTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IMediaType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaTypeService.Move is called in the API
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMediaType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MediaTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IMediaType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaTypeService.Move is called in the API, after the entities has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMediaType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MediaTypeChangedNotification -
      -
    • IEnumerable<MediaTypeChange<IMediaType>> Changes
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when a MediaType is saved or deleted, after the transaction has completed. This is mainly used for caching purposes, and generally not recommended, use Saved and Deleted notifications instead.
    - Changes will for each item affected by the change prove: -
      -
    1. Item: The IMediaType affected by the change.
    2. -
    3. ChangeTypes: The type of change: Create, Remove, RefreshMain, etc.
    4. -
    -
    diff --git a/10/umbraco-cms/reference/notifications/membertypeservice-notifications.md b/10/umbraco-cms/reference/notifications/membertypeservice-notifications.md deleted file mode 100644 index 1c8a6207047..00000000000 --- a/10/umbraco-cms/reference/notifications/membertypeservice-notifications.md +++ /dev/null @@ -1,139 +0,0 @@ ---- - - ---- - -# MemberTypeService Notifications - -The MemberTypeService class implements IMemberTypeService. It provides access to operations involving IMemberType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    MemberTypeSavingNotification -
      -
    • IEnumerable<IMemberType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IMemberType objects being saved. -
    MemberTypeSavedNotification -
      -
    • IEnumerable<IMemberType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberTypeService.Save is called in the API, after the entities has been saved.
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the collection of saved IMemberType objects. -
    MemberTypeDeletingNotification -
      -
    • IEnumerable<IMemberType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IMemberType objects being deleted. -
    MemberTypeDeletedNotification -
      -
    • IEnumerable<IMemberType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberTypeService.Delete is called in the API, after the entities has been deleted.
    - DeletedEntities: Gets the collection of deleted IMemberType objects. -
    MemberTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IMemberType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberTypeService.Move is called in the API
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMemberType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MemberTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IMemberType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberTypeService.Move is called in the API, after the entities has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMemberType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MemberTypeChangedNotification -
      -
    • IEnumerable<MemberTypeChange<IMemberType>> Changes
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when a MemberType is saved or deleted, after the transaction has completed. This is mainly used for caching purposes, and generally not recommended, use Saved and Deleted notifications instead.
    - Changes will for each item affected by the change prove: -
      -
    1. Item: The IMemberType affected by the change.
    2. -
    3. ChangeTypes: The type of change: Create, Remove, RefreshMain, etc.
    4. -
    -
    diff --git a/10/umbraco-cms/reference/notifications/relationservice-notifications.md b/10/umbraco-cms/reference/notifications/relationservice-notifications.md deleted file mode 100644 index 51bfbaa80ad..00000000000 --- a/10/umbraco-cms/reference/notifications/relationservice-notifications.md +++ /dev/null @@ -1,141 +0,0 @@ -# RelationService notifications - -The RelationService provides access to operations involving `IRelation` and `IRelationType`, and published the following relation notifications: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    RelationSavingNotification -
      -
    • IEnumerable<IRelation> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation is being saved.
    - SavedEntities: The collection of IRelation objects being saved.
    -
    RelationSavedNotification -
      -
    • IEnumerable<IRelation> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation has been saved.
    - SavedEntities: The collection of IRelation objects having been saved.
    -
    RelationDeletingNotification -
      -
    • IEnumerable<IRelation> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation is being deleted.
    - SavedEntities: The collection of IRelation objects being deleted.
    -
    RelationDeletedNotification -
      -
    • IEnumerable<IRelation> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation has been deleted.
    - SavedEntities: The collection of IRelation objects having been deleted.
    -
    RelationTypeSavingNotification -
      -
    • IEnumerable<IRelationType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type being saved.
    - SavedEntities: The collection of IRelationType objects being saved.
    -
    RelationTypeSavedNotification -
      -
    • IEnumerable<IRelationType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type has been saved.
    - SavedEntities: The collection of IRelationType objects having been saved.
    -
    RelationTypeDeletingNotification -
      -
    • IEnumerable<IRelationType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type is being deleted.
    - SavedEntities: The collection of IRelationType objects being deleted.
    -
    RelationTypeDeletedNotification -
      -
    • IEnumerable<IRelationType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type has been deleted.
    - SavedEntities: The collection of IRelationType objects having been deleted.
    -
    diff --git a/12/umbraco-cms/reference/notifications/contentypeservice-notifications.md b/12/umbraco-cms/reference/notifications/contentypeservice-notifications.md deleted file mode 100644 index 0f99644ca54..00000000000 --- a/12/umbraco-cms/reference/notifications/contentypeservice-notifications.md +++ /dev/null @@ -1,134 +0,0 @@ -# ContentTypeService Notifications - -The ContentTypeService class implements IContentTypeService. It provides access to operations involving IContentType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    ContentTypeSavingNotification -
      -
    • IEnumerable<IContentType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IContentType objects being saved. -
    ContentTypeSavedNotification -
      -
    • IEnumerable<IContentType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentTypeService.Save is called in the API, after the entities has been saved.
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the collection of saved IContentType objects. -
    ContentTypeDeletingNotification -
      -
    • IEnumerable<IContentType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IContentType objects being deleted. -
    ContentTypeDeletedNotification -
      -
    • IEnumerable<IContentType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentTypeService.Delete is called in the API, after the entities has been deleted.
    - DeletedEntities: Gets the collection of deleted IContentType objects. -
    ContentTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IContentType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentTypeService.Move is called in the API
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContentType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    ContentTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IContentType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentTypeService.Move is called in the API, after the entities has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContentType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    ContentTypeChangedNotification -
      -
    • IEnumerable<ContentTypeChange<IContentType>> Changes
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when a ContentType is saved or deleted, after the transaction has completed. This is mainly used for caching purposes, and generally not recommended, use Saved and Deleted notifications instead.
    - Changes will for each item affected by the change prove: -
      -
    1. Item: The IContentType affected by the change.
    2. -
    3. ChangeTypes: The type of change: Create, Remove, RefreshMain, etc.
    4. -
    -
    diff --git a/12/umbraco-cms/reference/notifications/datatypeservice-notifications.md b/12/umbraco-cms/reference/notifications/datatypeservice-notifications.md deleted file mode 100644 index ab374fb633a..00000000000 --- a/12/umbraco-cms/reference/notifications/datatypeservice-notifications.md +++ /dev/null @@ -1,116 +0,0 @@ -# DataTypeService Notifications - -The DataTypeService class implements IDataTypeService. It provides access to operations involving IDataType. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    DataTypeSavingNotification -
      -
    • IEnumerable<IDataType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when DataTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IDataType objects being saved. -
    DataTypeSavedNotification -
      -
    • IEnumerable<IDataType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when DataTypeService.Save is called in the API and after data has been persisted. - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the saved collection of IDataType objects. -
    DataTypeDeletingNotification -
      -
    • IEnumerable<IDataType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when DataTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IDataType objects being deleted. -
    DataTypeDeletedNotification -
      -
    • IEnumerable<IDataType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when DataTypeService.Delete is called in the API, after the IDataType objects has been deleted.
    - DeletedEntities: Gets the collection of deleted IDataType objects. -
    DataTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IDataType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when IDataTypeService.Move is called in the API.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IDataType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    DataTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IDataType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when IDataTypeService.Move is called in the API, after the IDataType has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the moved IDataType object
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    diff --git a/12/umbraco-cms/reference/notifications/fileservice-notifications.md b/12/umbraco-cms/reference/notifications/fileservice-notifications.md deleted file mode 100644 index 1b0e46f759f..00000000000 --- a/12/umbraco-cms/reference/notifications/fileservice-notifications.md +++ /dev/null @@ -1,210 +0,0 @@ -# FileService Notifications - -The FileService class implements IFileService. It provides access to operations involving IFile objects like scripts, stylesheets and templates. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    TemplateSavingNotification -
      -
    • IEnumerable<ITemplate> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    • string ContentTypeAlias
    • -
    • bool CreateTemplateForContentType
    • -
    -
    - Published when FileService.SaveTemplate is called in the API.
    -
      -
    1. SavedEntities: Gets the collection of ITemplate objects being saved.
    2. -
    3. ContentTypeAlias: The alias of the ContentType the template is for, this is used when creating a Document Type with Template, it's not recommended to try and change or set this.
    4. -
    5. CreateTemplateForContentType: Boolean value determining if the template is create for a Document Type, it's not recommended to change this value.
    6. -
    -
    TemplateSavedNotification -
      -
    • IEnumerable<ITemplate> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • string ContentTypeAlias
    • -
    • bool CreateTemplateForContentType
    • -
    -
    - Published when FileService.SaveTemplate is called in the API, after the template has been saved.
    -
      -
    1. SavedEntities: Gets the collection of saved ITemplate objects.
    2. -
    3. ContentTypeAlias: The alias of the ContentType the template is for, this is used when creating a Document Type with Template, it's not recommended to try and change this value.
    4. -
    5. CreateTemplateForContentType: Boolean value determining if the template is create for a Document Type, it's not recommended to change this value.
    6. -
    -
    ScriptSavingNotification -
      -
    • IEnumerable<IScript> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.SaveScript is called in the API.
    - SavedEntities: Gets the collection of IScript objects being saved. -
    ScriptSavedNotification -
      -
    • IEnumerable<IScript> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.SaveScript is called in the API, after the script has been saved.
    - SavedEntities: Gets the collection of saved IScript objects. -
    StylesheetSavingNotification -
      -
    • IEnumerable<IStylesheet> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.SaveStyleSheet is called in the API.
    - SavedEntities: Gets the collection of IStylesheet objects being saved. -
    StylesheetSavedNotification -
      -
    • IEnumerable<IStylesheet> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.SaveStylesheet is called in the API, after the script has been saved.
    - SavedEntities: Gets the collection of saved IStylesheet objects. -
    TemplateDeletingNotification -
      -
    • IEnumerable<ITemplate> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.DeleteTemplate is called in the API.
    - DeletedEntities: Gets the collection of ITemplate objects being deleted. -
    TemplateDeletedNotification -
      -
    • IEnumerable<ITemplate> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.DeleteTemplate is called in the API, after the template has been deleted.
    - DeletedEntities: Gets the collection of deleted ITemplate objects. -
    ScriptDeletingNotification -
      -
    • IEnumerable<IScript> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.DeleteScript is called in the API.
    - DeletedEntities: Gets the collection of IScript objects being deleted. -
    ScriptDeletedNotification -
      -
    • IEnumerable<IScript> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.DeleteScript is called in the API, after the script has been deleted.
    - DeletedEntities: Gets the collection of deleted IScript objects. -
    StylesheetDeletingNotification -
      -
    • IEnumerable<IStylesheet> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when FileService.DeleteStylesheet is called in the API.
    - DeletedEntities: Gets the collection of IStylesheet objects being deleted. -
    StylesheetDeletedNotification -
      -
    • IEnumerable<IStylesheet> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when FileService.DeleteStylesheet is called in the API, after the stylesheet has been deleted.
    - DeletedEntities: Gets the collection of deleted IStylesheet objects. -
    \ No newline at end of file diff --git a/12/umbraco-cms/reference/notifications/localizationservice-notifications.md b/12/umbraco-cms/reference/notifications/localizationservice-notifications.md deleted file mode 100644 index 0d9767af0a3..00000000000 --- a/12/umbraco-cms/reference/notifications/localizationservice-notifications.md +++ /dev/null @@ -1,135 +0,0 @@ -# LocalizationService Events - -The LocalizationService class implements ILocalizationService. It provides access to operations involving Language and DictionaryItem. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    LanguageSavingNotification -
      -
    • IEnumerable<ILanguage> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Save (ILanguage overload) is called in the API.
    - SavedEntities: Gets the collection of ILanguage objects being saved. -
    LanguageSavedNotification -
      -
    • IEnumerable<ILanguage> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - RPublished when LocalizationService.Save (ILanguage overload) is called in the API after data has been persisted.
    - SavedEntities: Gets the saved collection of ILanguage objects.. -
    DictionaryItemSavingNotification -
      -
    • IEnumerable<IDictionaryItem> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Save (IDictionaryItem overload) is called in the API.
    - SavedEntities: Gets the collection of IDictionaryItem objects being saved. -
    DictionaryItemSavedNotification -
      -
    • IEnumerable<IDictionaryItem> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when LocalizationService.Save (IDictionaryItem overload) is called in the API and the data has been persisted.
    - SavedEntities: Gets the saved collection of IDictionary objects. -
    LanguageDeletingNotification -
      -
    • IEnumerable<ILanguage> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Delete (ILanguage overload) is called in the API.
    - DeletedEntities: Gets the collection of ILanguage objects being deleted. -
    LanguageDeletedNotification -
      -
    • IEnumerable<ILanguage> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when LocalizationService.Delete (ILanguage overload) is called in the API, after the languages has been deleted.
    - DeletedEntities: Gets the collection of deleted ILanguage objects. -
    DictionaryItemDeletingNotification -
      -
    • IEnumerable<IDictionaryItem> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when LocalizationService.Delete (IDictionaryItem overload) is called in the API.
    - DeletedEntities: Gets the collection of IDictionaryItem objects being deleted -
    DictionaryItemDeletedNotification -
      -
    • IEnumerable<IDictionaryItem> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when LocalizationService.Delete (IDictionaryItem overload) is called in the API, after the dictionary items has been deleted.
    - DeletedEntities: Gets the collection of deleted IDictionaryItem objects. -
    \ No newline at end of file diff --git a/12/umbraco-cms/reference/notifications/mediatypeservice-notifications.md b/12/umbraco-cms/reference/notifications/mediatypeservice-notifications.md deleted file mode 100644 index c09e1392348..00000000000 --- a/12/umbraco-cms/reference/notifications/mediatypeservice-notifications.md +++ /dev/null @@ -1,134 +0,0 @@ -# MediaTypeService Notifications - -The MediaTypeService class implements IMediaTypeService. It provides access to operations involving IMediaType. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    MediaTypeSavingNotification -
      -
    • IEnumerable<IMediaType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IMediaType objects being saved. -
    MediaTypeSavedNotification -
      -
    • IEnumerable<IMediaType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaTypeService.Save is called in the API, after the entities has been saved.
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the collection of saved IMediaType objects. -
    MediaTypeDeletingNotification -
      -
    • IEnumerable<IMediaType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IMediaType objects being deleted. -
    MediaTypeDeletedNotification -
      -
    • IEnumerable<IMediaType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaTypeService.Delete is called in the API, after the entities has been deleted.
    - DeletedEntities: Gets the collection of deleted IMediaType objects. -
    MediaTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IMediaType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaTypeService.Move is called in the API
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMediaType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MediaTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IMediaType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaTypeService.Move is called in the API, after the entities has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMediaType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MediaTypeChangedNotification -
      -
    • IEnumerable<MediaTypeChange<IMediaType>> Changes
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when a MediaType is saved or deleted, after the transaction has completed. This is mainly used for caching purposes, and generally not recommended, use Saved and Deleted notifications instead.
    - Changes will for each item affected by the change prove: -
      -
    1. Item: The IMediaType affected by the change.
    2. -
    3. ChangeTypes: The type of change: Create, Remove, RefreshMain, etc.
    4. -
    -
    diff --git a/12/umbraco-cms/reference/notifications/membertypeservice-notifications.md b/12/umbraco-cms/reference/notifications/membertypeservice-notifications.md deleted file mode 100644 index e2ed4dd6089..00000000000 --- a/12/umbraco-cms/reference/notifications/membertypeservice-notifications.md +++ /dev/null @@ -1,134 +0,0 @@ -# MemberTypeService Notifications - -The MemberTypeService class implements IMemberTypeService. It provides access to operations involving IMemberType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    MemberTypeSavingNotification -
      -
    • IEnumerable<IMemberType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberTypeService.Save is called in the API.
    - SavedEntities: Gets the collection of IMemberType objects being saved. -
    MemberTypeSavedNotification -
      -
    • IEnumerable<IMemberType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberTypeService.Save is called in the API, after the entities has been saved.
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the collection of saved IMemberType objects. -
    MemberTypeDeletingNotification -
      -
    • IEnumerable<IMemberType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberTypeService.Delete is called in the API.
    - DeletedEntities: Gets the collection of IMemberType objects being deleted. -
    MemberTypeDeletedNotification -
      -
    • IEnumerable<IMemberType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberTypeService.Delete is called in the API, after the entities has been deleted.
    - DeletedEntities: Gets the collection of deleted IMemberType objects. -
    MemberTypeMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IMemberType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberTypeService.Move is called in the API
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMemberType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MemberTypeMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IMemberType>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberTypeService.Move is called in the API, after the entities has been moved.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMemberType object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MemberTypeChangedNotification -
      -
    • IEnumerable<MemberTypeChange<IMemberType>> Changes
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when a MemberType is saved or deleted, after the transaction has completed. This is mainly used for caching purposes, and generally not recommended, use Saved and Deleted notifications instead.
    - Changes will for each item affected by the change prove: -
      -
    1. Item: The IMemberType affected by the change.
    2. -
    3. ChangeTypes: The type of change: Create, Remove, RefreshMain, etc.
    4. -
    -
    diff --git a/12/umbraco-cms/reference/notifications/relationservice-notifications.md b/12/umbraco-cms/reference/notifications/relationservice-notifications.md deleted file mode 100644 index 51bfbaa80ad..00000000000 --- a/12/umbraco-cms/reference/notifications/relationservice-notifications.md +++ /dev/null @@ -1,141 +0,0 @@ -# RelationService notifications - -The RelationService provides access to operations involving `IRelation` and `IRelationType`, and published the following relation notifications: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    RelationSavingNotification -
      -
    • IEnumerable<IRelation> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation is being saved.
    - SavedEntities: The collection of IRelation objects being saved.
    -
    RelationSavedNotification -
      -
    • IEnumerable<IRelation> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation has been saved.
    - SavedEntities: The collection of IRelation objects having been saved.
    -
    RelationDeletingNotification -
      -
    • IEnumerable<IRelation> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation is being deleted.
    - SavedEntities: The collection of IRelation objects being deleted.
    -
    RelationDeletedNotification -
      -
    • IEnumerable<IRelation> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation has been deleted.
    - SavedEntities: The collection of IRelation objects having been deleted.
    -
    RelationTypeSavingNotification -
      -
    • IEnumerable<IRelationType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type being saved.
    - SavedEntities: The collection of IRelationType objects being saved.
    -
    RelationTypeSavedNotification -
      -
    • IEnumerable<IRelationType> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type has been saved.
    - SavedEntities: The collection of IRelationType objects having been saved.
    -
    RelationTypeDeletingNotification -
      -
    • IEnumerable<IRelationType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type is being deleted.
    - SavedEntities: The collection of IRelationType objects being deleted.
    -
    RelationTypeDeletedNotification -
      -
    • IEnumerable<IRelationType> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when a relation type has been deleted.
    - SavedEntities: The collection of IRelationType objects having been deleted.
    -
    From 05667162d6dcacc4a3a19f73175cd65693dfc70e Mon Sep 17 00:00:00 2001 From: "Alina-Magdalena Tincas (Umbraco HQ)" Date: Wed, 10 Apr 2024 16:19:50 +0200 Subject: [PATCH 3/5] updating other articles --- .../reference/notifications/README.md | 466 ++++++++++++----- .../cacherefresher-notifications.md | 75 +-- .../contentservice-notifications.md | 454 +--------------- .../mediaservice-notifications.md | 210 +------- .../memberservice-notifications.md | 110 +--- .../sendingallowedchildrennotifications.md | 4 - ...mbracoapplicationlifetime-notifications.md | 76 --- .../reference/notifications/README.md | 492 ++++++++++++------ .../cacherefresher-notifications.md | 11 +- .../contentservice-notifications.md | 41 +- .../mediaservice-notifications.md | 19 +- .../memberservice-notifications.md | 15 +- ...mbracoapplicationlifetime-notifications.md | 9 - .../sendingallowedchildrennotifications.md | 2 +- .../sendingallowedchildrennotifications.md | 2 +- 15 files changed, 719 insertions(+), 1267 deletions(-) diff --git a/10/umbraco-cms/reference/notifications/README.md b/10/umbraco-cms/reference/notifications/README.md index 0f672ab1025..9c7178b31e9 100644 --- a/10/umbraco-cms/reference/notifications/README.md +++ b/10/umbraco-cms/reference/notifications/README.md @@ -1,157 +1,387 @@ --- - - +description: Get started with Notifications. --- -# Using notifications +# Using Notifications -Umbraco uses Notifications, very similar to the Observer pattern, to allow you to hook into the workflow process for the backoffice. For example, you might want to execute some code every time a page is published. Notifications allow you to do that. +Umbraco uses Notifications (similar to the Observer pattern) to allow you to hook into the workflow process for the backoffice. For example, notifications allow you to execute some code every time a page is published. ## Notifications -All notifications reside in the `Umbraco.Cms.Core.Notifications` namespace and are postfixed with Notification. +All notifications reside in the `Umbraco.Cms.Core.Notifications` namespace and are postfixed with `Notification`. + +Available notifications typically exist in pairs, with "before" and "after" notifications. For example, the ContentService class has the concept of **publishing** and **published** notifications. So, there is both a `ContentPublishingNotification` and a `ContentPublishedNotification` notification. + +The notification to use depends on what you want to achieve. If you want to be able to cancel the action, you would use the `CancelOperation` method on the "before" notification. See the sample in [ContentService Notifications](contentservice-notifications.md). If you want to execute some code after the publishing has succeeded, then you would use the "after" notification. + +## Registering Notifications + +Check the [Notification Handler](./notification-handler.md) article to learn more about notification handlers lifetime, async notification handler and how to register the notification handlers. + +## List of Notifications + +Below you can find a list of most used object notifications. + +You can find a list of all supported notifications in the [API Docs](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.html). + +### Content, Media, and Member notifications + +
    + +**ContentService** Notifications + +The ContentService class is the most commonly used type when extending Umbraco using notifications. ContentService implements IContentService. It provides access to operations involving IContent. + +Below you can find a list of the most common ContentService object notifications. + +* [ContentSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentSavingNotification.html) + +* [ContentSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentSavedNotification.html) + +* [ContentPublishingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentPublishingNotification.html) + +* [ContentPublishedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentPublishedNotification.html) + +* [ContentUnpublishingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentUnpublishingNotification.html) + +* [ContentUnpublishedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentUnpublishedNotification.html) + +* [ContentCopyingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentCopyingNotification.html) + +* [ContentCopiedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentCopiedNotification.html) + +* [ContentMovingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovingNotification.html) + +* [ContentMovedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovedNotification.html) + +* [ContentMovingToRecycleBinNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovingToRecycleBinNotification.html) + +* [ContentMovedToRecycleBinNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovedToRecycleBinNotification.html) + +* [ContentDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletingNotification.html) + +* [ContentDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletedNotification.html) + +* [ContentDeletingVersionsNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletingVersionsNotification.html) + +* [ContentDeletedVersionsNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletedVersionsNotification.html) + +* [ContentRollingBackNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentRollingBackNotification.html) + +* [ContentRolledBackNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentRolledBackNotification.html) + +* [ContentSendingToPublishNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentSendingToPublishNotification.html) + +* [ContentSentToPublishNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentSentToPublishNotification.html) + +* [ContentEmptyingRecycleBinNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentEmptyingRecycleBinNotification.html) + +* [ContentEmptiedRecycleBinNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentEmptiedRecycleBinNotification.html) + +* [ContentSavedBlueprintNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentSavedBlueprintNotification.html) + +* [ContentDeletedBlueprintNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletedBlueprintNotification.html) + +
    + +
    + +**MediaService** Notifications + +Below you can find a list of the most common MediaService object notifications. + +* [MediaSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaSavingNotification.html) + +* [MediaSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaSavedNotification.html) + +* [MediaMovingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovingNotification.html) + +* [MediaMovedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovedNotification.html) + +* [MediaMovingToRecycleBinNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovingToRecycleBinNotification.html) + +* [MediaMovedToRecycleBinNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovedToRecycleBinNotification.html) + +* [MediaDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletingNotification.html) + +* [MediaDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletedNotification.html) + +* [MediaDeletingVersionsNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletingVersionsNotification.html) + +* [MediaDeletedVersionsNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletedVersionsNotification.html) + +
    + +
    + +**MemberService** Notifications + +The MemberService implements IMemberService and provides access to operations involving IMember. + +Below you can find a list of the most common MemberService object notifications. + +* [MemberSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberSavingNotification.html) + +* [MemberSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberSavedNotification.html) + +* [MemberDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberDeletingNotification.html) + +* [MemberDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberDeletedNotification.html) + +* [AssignedMemberRolesNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.AssignedMemberRolesNotification.html) + +* [RemovedMemberRolesNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.RemovedMemberRolesNotification.html) + +
    + +### Other notifications + +
    + +**ContentTypeService** Notifications + +The ContentTypeService class implements IContentTypeService. It provides access to operations involving IContentType. + +Below you can find a list of the most common ContentTypeService object notifications. + +* [ContentTypeSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeSavingNotification.html) + +* [ContentTypeSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeSavedNotification.html) + +* [ContentTypeDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeDeletingNotification.html) + +* [ContentTypeDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeDeletedNotification.html) + +* [ContentTypeMovingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeMovingNotification.html) + +* [ContentTypeMovedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeMovedNotification.html) + +* [ContentTypeChangedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeChangedNotification.html) + +
    + +
    + +**MediaTypeService** Notifications - object list + +The MediaTypeService class implements IMediaTypeService. It provides access to operations involving IMediaType. -Typically, available notifications exist in pairs, with a "before" and "after" notification. For example, the ContentService class has the concept of publishing and published notifications when this occurs. In that case, there is both a ContentPublishingNotification and a ContentPublishedNotification notification. +Below you can find a list of the most common MediaTypeService object notifications. -Which one you want to use depends on what you want to achieve. If you want to be able to cancel the action, you would use the "before" notification, and use the `CancelOperation` method on the notification to cancel it. See the sample in [ContentService Notifications](contentservice-notifications.md). If you want to execute some code after the publishing has succeeded, then you would use the "after" notification. +* [MediaTypeSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeSavingNotification.html) -### Notification handlers lifetime - -It's important to note that the handlers you create and register to receive notifications will be transient, this means that they will be initialized every time they receive a notification, so you cannot rely on them having a specific state based on previous notifications. For instance, you cannot create a list in a handler and add something when a notification is received, and then check if that list contains what you added in an earlier notification, that list will always be empty because the object has just been initialized. - -If you need persistence between notifications, we recommend that you move that functionality into a service or similar, and register it with the DI container, and then inject that into your handler. - -As previously mentioned a lot of notifications exist in pairs, with a "before" and "after" notification, there may be cases where you want to add some information to the "before" notification, which will then be available to your "after" notification handler, in order to support this, the notification "pairs" are stateful. This means that the notifications contain a dictionary that is shared between the "before" and "after" notification that you can add values to, and later get them from like this: +* [MediaTypeSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeSavedNotification.html) -```C# -public void Handle(TemplateSavingNotification notification) -{ - notification.State["SomeKey"] = "Some Value Relevant to the \"after\" notification handler"; -} - - -public void Handle(TemplateSavedNotification notification) -{ - var valueFromSaving = notification.State["SomeKey"]; -} -``` +* [MediaTypeDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeDeletingNotification.html) -### Registering notification handlers +* [MediaTypeDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeDeletedNotification.html) -Once you've made your notification handlers you need to register them with the `AddNotificationHandler` extension method on the `IUmbracoBuilder`, so they're run whenever a notification they subscribe to is published. There are two ways to do this: In the Startup class, if you're making handlers for your site, or a composer if you're a package developer subscribing to notifications. +* [MediaTypeMovingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeMovingNotification.html) -#### Registering notification handlers in the startup class +* [MediaTypeMovedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeMovedNotification.html) -In the Startup class register your notification handler in the `ConfigureServices` after `AddComposers()` but before `Build()`: +* [MediaTypeChangedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeChangedNotification.html) -```C# -public void ConfigureServices(IServiceCollection services) -{ -#pragma warning disable IDE0022 // Use expression body for methods - services.AddUmbraco(_env, _config) - .AddBackOffice() - .AddWebsite() - .AddComposers() - .AddNotificationHandler() - .Build(); -#pragma warning restore IDE0022 // Use expression body for methods +
    -} -``` +
    -The extension method takes two generic type parameters, the first `ContentPublishingNotification` is the notification you wish to subscribe to, the second `DontShout` is the class that handles the notification. This class must implement `INotificationHandler<>` with the type of notification it handles as the generic type parameter, in this case, the DontShout class definition looks like this: +**MemberTypeService** Notifications -```C# -public class DontShout : INotificationHandler -``` +The MemberTypeService class implements IMemberTypeService. It provides access to operations involving IMemberType -For the full handler implementation see [ContentService Notifications](contentservice-notifications.md). +Below you can find a list of the most common MemberTypeService object notifications. -#### Registering notification handlers in a composer +* [MemberTypeSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeSavingNotification.html) -If you're writing a package for Umbraco you won't have access to the Startup class, you can instead use a composer which gives you access to the `IUmbracoBuilder`, the rest is the same as when doing it in the Startup class: +* [MemberTypeSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeSavedNotification.html) -```C# -public class DontShoutComposer : IComposer -{ - public void Compose(IUmbracoBuilder builder) - { - builder.AddNotificationHandler(); - } -} -``` +* [MemberTypeDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeDeletingNotification.html) -#### Registering many notification handlers +* [MemberTypeDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeDeletedNotification.html) -You may want to subscribe to a lot of notifications, in this case, your `ConfigureServices` method or composer might end up being quite cluttered. You can avoid this by creating your own `IUmbracoBuilder` extension method for your events, keeping everything neatly wrapped up in one place, such an extension method can look like this: +* [MemberTypeMovingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeMovingNotification.html) -```C# -using Umbraco.Cms.Core.DependencyInjection; -using Umbraco.Cms.Core.Services.Notifications; +* [MemberTypeMovedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeMovedNotification.html) -namespace MySite -{ - public static class UmbracoBuilderNotificationExtensions - { - public static IUmbracoBuilder AddDontShoutNotifications(this IUmbracoBuilder builder) - { - builder - .AddNotificationHandler() - .AddNotificationHandler() - .AddNotificationHandler(); - - return builder; - } - } -} -``` +* [MemberTypeChangedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeChangedNotification.html) -You can then register all these notifications by calling `AddDontShoutNotifications` in `ConfigureServices` or your composer, just like you would `AddNotificationHandler`: +
    -```C# -public void ConfigureServices(IServiceCollection services) -{ -#pragma warning disable IDE0022 // Use expression body for methods - services.AddUmbraco(_env, _config) - .AddBackOffice() - .AddWebsite() - .AddComposers() - .AddDontShoutNotifications() - .Build(); -#pragma warning restore IDE0022 // Use expression body for methods - -} -``` - -Now all the notifications you registered in your extension method will be handled by your handler. - -## Content, Media, and Member notifications - -* See [ContentService Notifications](contentservice-notifications.md) for a listing of the ContentService object notifications. -* See [MediaService Notifications](mediaservice-notifications.md) for a listing of the MediaService object notifications. -* See [MemberService Notifications](membertypeservice-notifications.md) for a listing of the MemberService object notifications. +
    -## Other notifications +**DataTypeService** Notifications -* See [ContentTypeService Notifications](contentypeservice-notifications.md) for a listing of the ContentTypeService object notifications. -* See [MediaTypeService Notifications](mediatypeservice-notifications.md) for a listing of the MediaTypeService object notifications. -* See [MemberTypeService Notifications](membertypeservice-notifications.md) for a listing of the MemberTypeService object notifications. -* See [DataTypeService Notifications](datatypeservice-notifications.md) for a listing of the DataTypeService object notifications -* See [FileService Notifications](fileservice-notifications.md) for a listing of the FileService object notifications. -* See [LocalizationService Notifications](localizationservice-notifications.md) for a listing of the LocalizationService object notifications. +The DataTypeService class implements IDataTypeService. It provides access to operations involving IDataType. -## Tree notifications +Below you can find a list of the most common DataTypeService object notifications. -See [Tree Notifications](../../extending/section-trees/) for a listing of the tree notifications. - -## Editor Model Notifications - -See [EditorModel Notifications](editormodel-notifications/) for a listing of the EditorModel events +* [DataTypeSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeSavingNotification.html) + +* [DataTypeSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeSavedNotification.html) + +* [DataTypeDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeDeletingNotification.html) + +* [DataTypeDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeDeletedNotification.html) + +* [DataTypeMovingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeMovingNotification.html) + +* [DataTypeMovedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeMovedNotification.html) + +
    + +
    + +**FileService** Notifications + +The FileService class implements IFileService. It provides access to operations involving IFile objects like scripts, stylesheets and templates. + +Below you can find a list of the most common FileService object notifications. + +* [TemplateSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.TemplateSavingNotification.html) + +* [TemplateSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.TemplateSavedNotification.html) + +* [ScriptSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ScriptSavingNotification.html) + +* [ScriptSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ScriptSavedNotification.html) + +* [StylesheetSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetSavingNotification.html) + +* [StylesheetSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetSavedNotification.html) + +* [TemplateDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.TemplateDeletingNotification.html) + +* [TemplateDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.TemplateDeletedNotification.html) + +* [ScriptDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ScriptDeletingNotification.html) + +* [ScriptDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ScriptDeletedNotification.html) + +* [StylesheetDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetDeletingNotification.html) + +* [StylesheetDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetDeletedNotification.html) + +
    + +
    + +**LocalizationService** Notifications + +The LocalizationService class implements ILocalizationService. It provides access to operations involving Language and DictionaryItem. + +Below you can find a list of the most common LocalizationService object notifications. + +* [LanguageSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.LanguageSavingNotification.html) + +* [LanguageSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.LanguageSavedNotification.html) + +* [DictionaryItemSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemSavingNotification.html) + +* [DictionaryItemSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemSavedNotification.html) + +* [LanguageDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.LanguageDeletingNotification.html) + +* [LanguageDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.LanguageDeletedNotification.html) + +* [DictionaryItemDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemDeletingNotification.html) + +* [DictionaryItemDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemDeletedNotification.html) + +
    + +
    + +**CacheRefresher** Notifications + +Below you can find a list of the most common CacheRefresher object notifications. + +* [ContentCacheRefresherNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.ContentCacheRefresherNotification.html) + +* [MediaCacheRefresherNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MediaCacheRefresherNotification.html) + +* [MemberCacheRefresherNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.MemberCacheRefresherNotification.html) + +* [UserCacheRefresherNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.UserCacheRefresherNotification.html) + +
    + +
    + +**RelationService** Notifications + +Below you can find a list of the most common RelationService object notifications. + +The RelationService provides access to operations involving IRelation and IRelationType, and publishes the following relation notifications: + +* [RelationSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.RelationSavingNotification.html) + +* [RelationSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.RelationSavedNotification.html) + +* [RelationDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.RelationDeletingNotification.html) + +* [RelationDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.RelationDeletedNotification.html) + +* [RelationTypeSavingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeSavingNotification.html) + +* [RelationTypeSavedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeSavedNotification.html) + +* [RelationTypeDeletingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeDeletingNotification.html) + +* [RelationTypeDeletedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeDeletedNotification.html) + +
    + +
    + +**UmbracoApplicationLifetime** Notifications + +Represents an Umbraco application lifetime (starting, started, stopping, stopped) notification. + +Below you can find a list of the most common UmbracoApplicationLifetime object notifications. + +* [UmbracoApplicationStartingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStartingNotification.html) + +* [UmbracoApplicationStartedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStartedNotification.html) + +* [UmbracoApplicationStoppingNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStoppingNotification.html) + +* [UmbracoApplicationStoppedNotification](https://apidocs.umbraco.com/v10/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStoppedNotification.html) + +
    + +### Tree notifications + +See [Tree Notifications](../../extending/section-trees/) for a list of the tree notifications. + +### Editor Model Notifications + +See [EditorModel Notifications](editormodel-notifications/) for a list of the EditorModel events. {% hint style="info" %} -Useful for manipulating the model before it is sent to an editor in the backoffice - e.g. perhaps to set a default value of a property on a new document. +Useful for manipulating the model before it is sent to an editor in the backoffice. It could be used to set a default value of a property on a new document. {% endhint %} ## Creating and publishing your own custom notifications -Umbraco uses notifications to allow people to hook into various workflow processes. This notification pattern is extensible, allowing you to create and publish your own custom notifications, thus allowing other people to observe and hook into your custom processes. This approach can be very useful when creating Umbraco packages. For more information on how you create and publish your own notifications see the [creating and publishing notifications](creating-and-publishing-notifications.md) article. +Umbraco uses notifications to allow people to hook into different workflow processes. This notification pattern is extensible, allowing you to create and publish custom notifications, and other people to observe and hook into your custom processes. This approach can be very useful when creating Umbraco packages. For more information on how you create and publish your own notifications, see the [creating and publishing notifications](creating-and-publishing-notifications.md) article. + +## Samples + +Below you can find some articles with some examples using Notifications. + +* [CacheRefresher Notification](./cacherefresher-notifications.md) + +* [ContentService Notifications](./contentservice-notifications.md) + +* [Determining if an entity is new](./determining-new-entity.md) + +* [Hot vs. cold restarts](./hot-vs-cold-restarts.md) + +* [MediaService Notifications](./mediaservice-notifications.md) + +* [MemberService Notifications](./memberservice-notifications.md) + +* [Sending Allowed Children Notification](./sendingallowedchildrennotifications.md) + +* [Umbraco Application Lifetime Notifications](./umbracoapplicationlifetime-notifications.md) diff --git a/10/umbraco-cms/reference/notifications/cacherefresher-notifications.md b/10/umbraco-cms/reference/notifications/cacherefresher-notifications.md index 3a238b58be5..915e7fca320 100644 --- a/10/umbraco-cms/reference/notifications/cacherefresher-notifications.md +++ b/10/umbraco-cms/reference/notifications/cacherefresher-notifications.md @@ -1,3 +1,7 @@ +--- +description: Example of how to use a CacheRefresher Notification +--- + # Cache Refresher Notifications Before starting with cache refresher notifications it's a good idea to ensure you need to use them. If you want to react to changes in content, for instance, there's no real reason to use these notifications. This is due to the [content service notifications](contentservice-notifications.md) being easier to work with. If you need to react to changes in the cache, then these are the notifications for you. @@ -64,7 +68,7 @@ public enum TreeChangeTypes : byte ``` -An example of working with the `ContentCacheNotification` can be seen here: +An example of working with the `ContentCacheNotification` can be seen here: ```C# using Umbraco.Cms.Core.Cache; @@ -105,72 +109,3 @@ public class ContentCacheRefresherExample : INotificationHandler - - Notification - Members - Description - - - - ContentCacheRefresherNotification - -
      -
    • object MessageObject
    • -
    • MessageType MessageType
    • -
    - - - Published when the content cache has been updated.
    - MessageObject: The refresher payload.
    - MessageType: The type of cache refresher message.
    - - - - - MediaCacheRefresherNotification - -
      -
    • object MessageObject
    • -
    • MessageType MessageType
    • -
    - - - Published when the media cache has been updated.
    - MessageObject: The refresher payload.
    - MessageType: The type of cache refresher message.
    - - - - - MemberCacheRefresherNotification - -
      -
    • object MessageObject
    • -
    • MessageType MessageType
    • -
    - - - Published when the member cache has been updated.
    - MessageObject: The refresher payload.
    - MessageType: The type of cache refresher message.
    - - - - - UserCacheRefresherNotification - -
      -
    • object MessageObject
    • -
    • MessageType MessageType
    • -
    - - - Published when the user cache has been updated.
    - MessageObject: The refresher payload.
    - MessageType: The type of cache refresher message.
    - - - - diff --git a/10/umbraco-cms/reference/notifications/contentservice-notifications.md b/10/umbraco-cms/reference/notifications/contentservice-notifications.md index 944b3457d6b..fdaa4158942 100644 --- a/10/umbraco-cms/reference/notifications/contentservice-notifications.md +++ b/10/umbraco-cms/reference/notifications/contentservice-notifications.md @@ -1,8 +1,8 @@ --- - - +description: Find out more about ContentService Notifications and explore some example of how to use it --- + # ContentService Notifications The ContentService class is the most commonly used type when extending Umbraco using notifications. ContentService implements IContentService. It provides access to operations involving IContent. @@ -41,448 +41,6 @@ namespace Umbraco.Docs.Samples.Web.Notifications The handler will also need to be registered. See the [Notifications article](https://docs.umbraco.com/umbraco-cms/reference/notifications#registering-notification-handlers) for specifics on how to do this. -## Notifications - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    ContentSavingNotification -
      -
    • IEnumerable<IContent> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when the IContentService.Save is called in the API.
    - NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    - SavedEntities: The collection of IContent objects being saved.
    NOTE: If the entity is brand new then HasIdentity will equal false. -
    ContentSavedNotification -
      -
    • IEnumerable<IContent> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when IContentService.Save is called in the API and after data has been persisted.
    - NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: The saved collection of IContent objects. -
    ContentPublishingNotification -
      -
    • IEnumerable<IContent> PublishedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when IContentService.Publishing is called in the API.
    - NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Publish method call (true by default).
    - NOTE: If the entity is brand new then HasIdentity will equal false.
    - PublishedEntities: The collection of IContent objects being published. -
    ContentPublishedNotification -
      -
    • IEnumerable<IContent> PublishedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when IContentService.Publish is called in the API and after data has been published.
    - NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Publish method call (true by default).
    - NOTE: See here on how to determine if the entity is brand new
    - PublishedEntities: The published collection of IContent objects. -
    ContentUnpublishingNotification -
      -
    • IEnumerable<IContent> UnpublishedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when IContentService.UnPublishing is called in the API.
    - UnpublishedEntities: The collection of IContent being unpublished. -
    ContentUnpublishedNotification -
      -
    • IEnumerable<IContent> UnpublishedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when IContentService.UnPublish is called in the API and after data has been unpublished.
    - UnpublishedEntities: The collection of unpublished IContent. -
    ContentCopyingNotification -
      -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    • IContent Original
    • -
    • IContent Copy
    • -
    • int ParentId
    • -
    -
    - Published when IContentService.Copy is called in the API.
    - The notification is published after a copy object has been created and had its parentId updated and its state has been set to unpublished.
    -
      -
    1. Original: Gets the original IContent object.
    2. -
    3. Copy: Gets the IContent object being copied.
    4. -
    5. ParentId: Gets the Id of the parent of the IContent being copied.
    6. -
    -
    ContentCopiedNotification -
      -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • IContent Original
    • -
    • IContent Copy
    • -
    • int ParentId
    • -
    • bool RelateToOriginal
    • -
    -
    - Published when IContentService.Copy is called in the API.
    - The notification is published after the content object has been copied.
    -
      -
    1. Original: Gets the original IContent object.
    2. -
    3. Copy: Gets the IContent object being copied.
    4. -
    5. ParentId: Gets the Id of the parent of the IContent being copied.
    6. -
    7. RelateToOriginal: Boolean indicating whether the copy was related to the original
    8. -
    -
    ContentMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when IContentService.Move is called in the API.
    - NOTE: If the target parent is the Recycle bin, this notification is never published. Try the ContentMovingToRecycleBinNotification instead.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContent object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    ContentMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when IContentService.Move is called in the API. - The notification is published after the content object has been moved.
    - NOTE: If the target parent is the Recycle bin, this notification is never published. Try the ContentMovedToRecycleBinNotification instead.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContent object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    ContentMovingToRecycleBinNotification -
      -
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentService.MoveToRecycleBin is called in the API.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContent object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the RecycleBin
    6. -
    -
    ContentMovedToRecycleBinNotification -
      -
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentService.MoveToRecycleBin is called in the API. Is published after the content has been moved to the RecycleBin
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IContent object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the RecycleBin
    6. -
    -
    ContentDeletingNotification -
      -
    • IEnumerable<IContent> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentService.DeleteContentOfType, ContentService.Delete, ContentService.EmptyRecycleBin are called in the API.
    - DeletedEntities: Gets the collection of IContent objects being deleted. -
    ContentDeletedNotification -
      -
    • IEnumerable<IContent> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    Published when ContentService.Delete, ContentService.EmptyRecycleBin are called in the API, and the entity has been deleted.
    - DeletedEntities: Gets the collection of deleted IContent objects. -
    ContentDeletingVersionsNotification -
      -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    • int Id
    • -
    • int SpecificVersion
    • -
    • DateTime DateToRetain
    • -
    • bool DeletePriorVersions
    • -
    -
    - Published when ContentService.DeleteVersion, ContentService.DeleteVersions are called in the API.
    -
      -
    1. Id: Gets the id of the IContent object being deleted.
    2. -
    3. DateToRetain: Gets the latest version date.
    4. -
    5. SpecificVersion: Gets the id of the IContent object version being deleted.
    6. -
    7. DeletePriorVersions: False by default
    8. -
    -
    ContentDeletedVersionsNotification -
      -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • int Id
    • -
    • int SpecificVersion
    • -
    • DateTime DateToRetain
    • -
    • bool DeletePriorVersions
    • -
    -
    Published when ContentService.DeleteVersion, ContentService.DeleteVersions are called in the API, and the version has been deleted.
    -
      -
    1. Id: Gets the id of the IContent object being deleted.
    2. -
    3. DateToRetain: Gets the latest version date.
    4. -
    5. SpecificVersion: Gets the id of the IContent object version being deleted.
    6. -
    7. DeletePriorVersions: False by default
    8. -
    -
    ContentRollingBackNotification -
      -
    • IContent Entity
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentService.Rollback is called in the API.
    - Entity: Gets the IContent object being rolled back. -
    ContentRolledBackNotification -
      -
    • IContent Entity
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentService.Rollback is called in the API, after the content has been rolled back.
    - Entity: Gets the IContent object being rolled back. -
    ContentSendingToPublishNotification -
      -
    • IContent Entity
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentService.SendToPublication is called in the API.
    - Entity: Gets the IContent object being sent to publish. -
    ContentSentToPublishNotification -
      -
    • IContent Entity
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentService.SendToPublication is called in the API, after the entity has been sent to publication.
    - Entity: Gets the IContent object being sent to publish. -
    ContentEmptyingRecycleBinNotification -
      -
    • IEnumerable<IContent> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when ContentService.EmptyRecycleBin is called in the API.
    - DeletedEntities: The collection of IContent objects being deleted. -
    ContentEmptiedRecycleBinNotification -
      -
    • IEnumerable<IContent> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentService.EmptyRecycleBin is called in the API, after the RecycleBin has been emptied.
    - DeletedEntities: The collection of deleted IContent object. -
    ContentSavedBlueprintNotification -
      -
    • IContent SavedBlueprint
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentService.SavedBlueprint is called in the API.
    - SavedBlueprint: Gets the saved blueprint IContent object -
    ContentDeletedBlueprintNotification -
      -
    • IEnumerable<IContent> DeletedBlueprints
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when ContentService.DeletedBlueprint is called in the API.
    - DeletedBlueprints: The collection of deleted blueprint IContent -
    - ### Variants and Notifications Umbraco V8 introduced the concept of Variants for Document Types, initially to allow different language variants of particular properties within a Document Type to be edited/translated based on the languages configured in your instance of Umbraco. @@ -533,10 +91,10 @@ When handling the Unpublishing notification, it might not work how you would exp ```C# public void Handle(ContentUnpublishingNotification notification) { - foreach (var unPublishedEntity in notification.UnpublishedEntities) - { - // complete unpublishing of entity, all cultures - } + foreach (var unPublishedEntity in notification.UnpublishedEntities) + { + // complete unpublishing of entity, all cultures + } } ``` diff --git a/10/umbraco-cms/reference/notifications/mediaservice-notifications.md b/10/umbraco-cms/reference/notifications/mediaservice-notifications.md index 3e90602b78e..31cc1c1083f 100644 --- a/10/umbraco-cms/reference/notifications/mediaservice-notifications.md +++ b/10/umbraco-cms/reference/notifications/mediaservice-notifications.md @@ -1,3 +1,7 @@ +--- +description: Example of how to use a MediaService Notification +--- + # MediaService Notifications The MediaService class implements IMediaService. It provides access to operations involving IMedia. @@ -77,212 +81,6 @@ namespace MyProject ![image](https://github.com/umbraco/UmbracoDocs/assets/6904597/67696298-2710-4aeb-bd0a-33c6d8414216) -## Events - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    MediaSavingNotification -
      -
    • IEnumerable<IMedia> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaService.Save is called in the API.
    - NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    - SavedEntities: Gets the collection of IMedia objects being saved. -
    MediaSavedNotification -
      -
    • IEnumerable<IMedia> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaService.Save is called in the API and after the data has been persisted.
    - NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    - SavedEntities: Gets the saved collection of IMedia objects. -
    MediaMovingNotification -
      -
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaService.Move is called in the API.
    - NOTE: If the target parent is the Recycle bin, this notification is never published. Try the MediaMovingToRecycleBinNotification instead.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMedia object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MediaMovedNotification -
      -
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaService.Move is called in the API. - The event is fired after the media object has been moved.
    - NOTE: If the target parent is the Recycle bin, this notification is never published. Try the MediaMovedToRecycleBinNotification instead.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMedia object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    6. -
    -
    MediaMovingToRecycleBinNotification -
      -
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaService.MoveToRecycleBin is called in the API.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMedia object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the RecycleBin
    6. -
    -
    MediaMovedToRecycleBinNotification -
      -
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaService.MoveToRecycleBin is called in the API, after the media object has been moved to the RecycleBin.
    - MoveInfoCollection will for each moving entity provide: -
      -
    1. Entity: Gets the IMedia object being moved
    2. -
    3. OriginalPath: The original path the entity is moved from
    4. -
    5. NewParentId: Gets the Id of the RecycleBin
    6. -
    -
    MediaDeletingNotification -
      -
    • IEnumerable<IMedia> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MediaService.DeleteMediaOfType, MediaService.Delete, MediaService.EmptyRecycleBin are called in the API.
    - DeletedEntities: Gets the collection of IMedia objects being deleted. -
    MediaDeletedNotification -
      -
    • IEnumerable<IMedia> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MediaService.Delete, MediaService.EmptyRecycleBin are called in the API, after the media has been deleted.
    - DeletedEntities: Gets the collection of deleted IMedia objects. -
    MediaDeletingVersionsNotification -
      -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    • int Id
    • -
    • int SpecificVersion
    • -
    • DateTime DateToRetain
    • -
    • bool DeletePriorVersions
    • -
    -
    - Published when MediaService.DeleteVersion, MediaService.DeleteVersions are called in the API.
    -
      -
    1. Id: Gets the id of the IMedia object being deleted.
    2. -
    3. DateToRetain: Gets the latest version date.
    4. -
    5. SpecificVersion: Gets the id of the IMedia object version being deleted.
    6. -
    7. DeletePriorVersions: False by default
    8. -
    -
    MediaDeletedVersionsNotification -
      -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • int Id
    • -
    • int SpecificVersion
    • -
    • DateTime DateToRetain
    • -
    • bool DeletePriorVersions
    • -
    -
    - Published when MediaService.DeleteVersion, MediaService.DeleteVersions are called in the API, after the media version has been deleted
    -
      -
    1. Id: Gets the id of the deleted IMedia object.
    2. -
    3. DateToRetain: Gets the latest version date.
    4. -
    5. SpecificVersion: Gets the id of the deleted IMedia object version.
    6. -
    7. DeletePriorVersions: False by default
    8. -
    -
    - ### What happened to Creating and Created events? Both the MediaService.Creating and MediaService.Created events have been obsoleted. Because of this, these were not moved over to notifications, and no longer exist. Why? Because these events were not guaranteed to trigger and therefore should not have been used. This is because these events *only* triggered when the MediaService.CreateMedia method was used which is an entirely optional way to create media entities. It is also possible to construct a new media item - which is generally the preferred and consistent way - and therefore the Creating/Created events would not execute when constructing media that way. diff --git a/10/umbraco-cms/reference/notifications/memberservice-notifications.md b/10/umbraco-cms/reference/notifications/memberservice-notifications.md index 146cb7374b8..95255854483 100644 --- a/10/umbraco-cms/reference/notifications/memberservice-notifications.md +++ b/10/umbraco-cms/reference/notifications/memberservice-notifications.md @@ -1,6 +1,5 @@ --- - - +description: Example of how to use a MemberService Notification --- # MemberService Notifications @@ -36,110 +35,3 @@ namespace MySite } } ``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    MemberSavingNotification -
      -
    • IEnumerable<IMember> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberService.Saving is called in the API.
    - NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    - SavedEntities: Gets the collection of IMember objects being saved. -
    MemberSavedNotification -
      -
    • IEnumerable<IMember> SavedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberService.Save is called in the API and after data has been persisted.
    - NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    - NOTE: See here on how to determine if the entity is brand new
    - SavedEntities: Gets the saved collection of IMember objects. -
    MemberDeletingNotification -
      -
    • IEnumerable<IMember> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    • bool Cancel
    • -
    -
    - Published when MemberService.Delete, and MemberService.DeleteMembersOfType are called in the API.
    - DeletedEntities: Gets the collection of IMember objects being deleted. -
    MemberDeletedNotification -
      -
    • IEnumerable<IMember> DeletedEntities
    • -
    • EventMessages Messages
    • -
    • IDictionary<string,object> State
    • -
    -
    - Published when MemberService.Delete, and MemberService.DeleteMembersOfType are called in the API, after the members has been deleted.
    - DeletedEntities: Gets the collection of deleted IMember objects. -
    AssignedMemberRolesNotification -
      -
    • string[] Roles
    • -
    • int[] MemberIds
    • -
    -
    - Published when MemberService.AssignRoles, and MemberService.ReplaceRoles are called in the API. -
      -
    1. Roles: Collection of role names being assigned.
    2. -
    3. MemberIds: Collection of Ids of the members the roles are being assigned to.
    4. -
    -
    RemovedMemberRolesNotification -
      -
    • string[] Roles
    • -
    • int[] MemberIds
    • -
    -
    - Published when MemberService.DissociateRoles are being called in the API. -
      -
    1. Roles: Collection of role names being removed.
    2. -
    3. MemberIds: Collection of Ids of the members the roles are being removed from.
    4. -
    -
    diff --git a/10/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md b/10/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md index 2baf708c010..e39ff6116af 100644 --- a/10/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md +++ b/10/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md @@ -1,7 +1,3 @@ ---- -versionFrom: 9.5.0 ---- - # Sending Allowed Children Notification The `SendingAllowedChildrenNotification` enables you to manipulate the Document Types that will be shown in the create menu when adding new content in the backoffice. diff --git a/10/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md b/10/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md index face8709be2..860551c4ad8 100644 --- a/10/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md +++ b/10/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md @@ -1,7 +1,4 @@ --- -versionFrom: 9.3.0 - -meta-title: Umbraco Application Lifetime Notifications description: Represents an Umbraco application lifetime (starting, started, stopping, stopped) notification --- @@ -50,76 +47,3 @@ public class UmbracoApplicationNotificationHandler : INotificationHandler _logger.LogInformation("{Type} - {IsRestarting}", notification.GetType().Name, isRestarting); } ``` - -## Notifications - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NotificationMembersDescription
    UmbracoApplicationStartingNotification -
      -
    • RuntimeLevel RuntimeLevel
    • -
    • bool IsRestarting
    • -
    -
    - Triggered when the application is starting after all IComponents are initialized but before any incoming requests are accepted.
    -
      -
    1. RuntimeLevel: Gets the runtime level.
    2. -
    3. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    4. -
    -
    UmbracoApplicationStartedNotification -
      -
    • bool IsRestarting
    • -
    -
    - Triggered when the application has fully started and is accepting incoming requests.
    -
      -
    1. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    2. -
    -
    UmbracoApplicationStoppingNotification -
      -
    • bool IsRestarting
    • -
    -
    - Triggered when the application is performing a graceful shutdown after all IComponents are terminated.
    -
      -
    1. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    2. -
    -
    UmbracoApplicationStoppedNotification -
      -
    • bool IsRestarting
    • -
    -
    - Triggered when the application has performed a graceful shutdown.
    -
      -
    1. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    2. -
    -
    diff --git a/12/umbraco-cms/reference/notifications/README.md b/12/umbraco-cms/reference/notifications/README.md index 4f6d2319a04..34ffec73a23 100644 --- a/12/umbraco-cms/reference/notifications/README.md +++ b/12/umbraco-cms/reference/notifications/README.md @@ -1,3 +1,7 @@ +--- +description: Get started with Notifications. +--- + # Using Notifications Umbraco uses Notifications (similar to the Observer pattern) to allow you to hook into the workflow process for the backoffice. For example, notifications allow you to execute some code every time a page is published. @@ -10,201 +14,349 @@ Available notifications typically exist in pairs, with "before" and "after" noti The notification to use depends on what you want to achieve. If you want to be able to cancel the action, you would use the `CancelOperation` method on the "before" notification. See the sample in [ContentService Notifications](contentservice-notifications.md). If you want to execute some code after the publishing has succeeded, then you would use the "after" notification. -### Notification handlers lifetime +## Registering Notifications + +Check the [Notification Handler](./notification-handler.md) article to learn more about notification handlers lifetime, async notification handler and how to register the notification handlers. + +## List of Notifications + +Below you can find a list of most used object notifications. + +You can find a list of all supported notifications in the [API Docs](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.html). + +### Content, Media, and Member notifications + +
    + +**ContentService** Notifications + +The ContentService class is the most commonly used type when extending Umbraco using notifications. ContentService implements IContentService. It provides access to operations involving IContent. + +Below you can find a list of the most common ContentService object notifications. + +* [ContentSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentSavingNotification.html) + +* [ContentSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentSavedNotification.html) + +* [ContentPublishingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentPublishingNotification.html) + +* [ContentPublishedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentPublishedNotification.html) + +* [ContentUnpublishingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentUnpublishingNotification.html) + +* [ContentUnpublishedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentUnpublishedNotification.html) + +* [ContentCopyingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentCopyingNotification.html) + +* [ContentCopiedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentCopiedNotification.html) + +* [ContentMovingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovingNotification.html) + +* [ContentMovedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovedNotification.html) + +* [ContentMovingToRecycleBinNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovingToRecycleBinNotification.html) + +* [ContentMovedToRecycleBinNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentMovedToRecycleBinNotification.html) + +* [ContentDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletingNotification.html) + +* [ContentDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletedNotification.html) + +* [ContentDeletingVersionsNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletingVersionsNotification.html) + +* [ContentDeletedVersionsNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletedVersionsNotification.html) + +* [ContentRollingBackNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentRollingBackNotification.html) + +* [ContentRolledBackNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentRolledBackNotification.html) + +* [ContentSendingToPublishNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentSendingToPublishNotification.html) + +* [ContentSentToPublishNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentSentToPublishNotification.html) + +* [ContentEmptyingRecycleBinNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentEmptyingRecycleBinNotification.html) + +* [ContentEmptiedRecycleBinNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentEmptiedRecycleBinNotification.html) + +* [ContentSavedBlueprintNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentSavedBlueprintNotification.html) + +* [ContentDeletedBlueprintNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentDeletedBlueprintNotification.html) + +
    + +
    + +**MediaService** Notifications + +Below you can find a list of the most common MediaService object notifications. + +* [MediaSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaSavingNotification.html) + +* [MediaSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaSavedNotification.html) + +* [MediaMovingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovingNotification.html) + +* [MediaMovedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovedNotification.html) + +* [MediaMovingToRecycleBinNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovingToRecycleBinNotification.html) + +* [MediaMovedToRecycleBinNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaMovedToRecycleBinNotification.html) + +* [MediaDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletingNotification.html) + +* [MediaDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletedNotification.html) + +* [MediaDeletingVersionsNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletingVersionsNotification.html) + +* [MediaDeletedVersionsNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaDeletedVersionsNotification.html) + +
    + +
    + +**MemberService** Notifications + +The MemberService implements IMemberService and provides access to operations involving IMember. + +Below you can find a list of the most common MemberService object notifications. + +* [MemberSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberSavingNotification.html) + +* [MemberSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberSavedNotification.html) + +* [MemberDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberDeletingNotification.html) + +* [MemberDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberDeletedNotification.html) + +* [AssignedMemberRolesNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.AssignedMemberRolesNotification.html) + +* [RemovedMemberRolesNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.RemovedMemberRolesNotification.html) + +
    + +### Other notifications + +
    + +**ContentTypeService** Notifications + +The ContentTypeService class implements IContentTypeService. It provides access to operations involving IContentType. + +Below you can find a list of the most common ContentTypeService object notifications. + +* [ContentTypeSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeSavingNotification.html) + +* [ContentTypeSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeSavedNotification.html) + +* [ContentTypeDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeDeletingNotification.html) + +* [ContentTypeDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeDeletedNotification.html) + +* [ContentTypeMovingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeMovingNotification.html) + +* [ContentTypeMovedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeMovedNotification.html) + +* [ContentTypeChangedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentTypeChangedNotification.html) + +
    + +
    -It's important to know that the handlers you create and register to receive notifications will be **transient**. This means that they will be initialized every time they receive a notification. You can therefore not rely on them having a specific state based on previous notifications. +**MediaTypeService** Notifications - object list -As an example, you cannot do the following: +The MediaTypeService class implements IMediaTypeService. It provides access to operations involving IMediaType. -1. Create a list in a handler. -2. Add something when a notification is received. -3. Check if that list contains what you added in an earlier notification. +Below you can find a list of the most common MediaTypeService object notifications. -When following the steps above, the list will always be empty because the object has only been initialized. +* [MediaTypeSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeSavingNotification.html) -If you need persistence between notifications, we recommend you move that functionality into a service or similar. You can then register it with the DI container, and inject it into your handler. +* [MediaTypeSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeSavedNotification.html) -As previously mentioned, many notifications exist in pairs, with a "before" and "after" notification. There may be cases where you want to add some information to the "before" notification, which will then be available to your "after" notification handler. In order to support this, the notification "pairs" are **stateful**. This means the notifications contain a dictionary that is shared between the "before" and "after" notifications. You can add values to the dictionary, and later retrieve them like this: +* [MediaTypeDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeDeletingNotification.html) -```csharp -public void Handle(TemplateSavingNotification notification) -{ - notification.State["SomeKey"] = "Some Value Relevant to the \"after\" notification handler"; -} - - -public void Handle(TemplateSavedNotification notification) -{ - var valueFromSaving = notification.State["SomeKey"]; -} -``` +* [MediaTypeDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeDeletedNotification.html) -### Registering notification handlers +* [MediaTypeMovingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeMovingNotification.html) -Once you've made your notification handlers, you need to register them with the `AddNotificationHandler` extension method on the `IUmbracoBuilder`. This enables them to run whenever a notification they subscribe to is published. There are two ways to do this: +* [MediaTypeMovedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeMovedNotification.html) -1. In the **Startup** class, if you're making handlers for your site -2. In a [**composer**](../../implementation/composing.md), if you're a package developer subscribing to notifications +* [MediaTypeChangedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaTypeChangedNotification.html) -#### Registering notification handlers in the startup class +
    -In the Startup class, register your notification handler in the `ConfigureServices` after `AddComposers()` but before `Build()`: +
    -```csharp -public void ConfigureServices(IServiceCollection services) -{ -#pragma warning disable IDE0022 // Use expression body for methods - services.AddUmbraco(_env, _config) - .AddBackOffice() - .AddWebsite() - .AddComposers() - .AddNotificationHandler() - .Build(); -#pragma warning restore IDE0022 // Use expression body for methods +**MemberTypeService** Notifications -} -``` +The MemberTypeService class implements IMemberTypeService. It provides access to operations involving IMemberType -The extension method takes two generic type parameters. The first, `ContentPublishingNotification`, is the notification you wish to subscribe to. The second, `DontShout`, is the class that handles the notification. This class must implement `INotificationHandler<>` with the type of notification it handles as the generic type parameter. In this case, the `DontShout` class definition looks like this: +Below you can find a list of the most common MemberTypeService object notifications. -```csharp -public class DontShout : INotificationHandler -``` +* [MemberTypeSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeSavingNotification.html) -For the full handler implementation, see [ContentService Notifications](contentservice-notifications.md). +* [MemberTypeSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeSavedNotification.html) -#### Registering notification handlers in a composer +* [MemberTypeDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeDeletingNotification.html) -If you're writing a package for Umbraco you won't have access to the Startup class. You can instead use a composer, which gives you access to the `IUmbracoBuilder`. the rest is the same as when doing it in the Startup class: +* [MemberTypeDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeDeletedNotification.html) -```csharp -public class DontShoutComposer : IComposer -{ - public void Compose(IUmbracoBuilder builder) - { - builder.AddNotificationHandler(); - } -} -``` +* [MemberTypeMovingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeMovingNotification.html) -#### Registering many notification handlers +* [MemberTypeMovedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeMovedNotification.html) -You may want to subscribe to many notifications, meaning your `ConfigureServices` method or composer might become cluttered. You can avoid this by creating your own `IUmbracoBuilder` extension method for your events, keeping everything neatly wrapped up in one place, as follows: +* [MemberTypeChangedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberTypeChangedNotification.html) -```csharp -using Umbraco.Cms.Core.DependencyInjection; -using Umbraco.Cms.Core.Services.Notifications; +
    -namespace MySite; +
    -public static class UmbracoBuilderNotificationExtensions -{ - public static IUmbracoBuilder AddDontShoutNotifications(this IUmbracoBuilder builder) - { - builder - .AddNotificationHandler() - .AddNotificationHandler() - .AddNotificationHandler(); - - return builder; - } -} -``` +**DataTypeService** Notifications -You can then register all these notifications by calling `AddDontShoutNotifications` in `ConfigureServices` or your composer, just like you would `AddNotificationHandler`: +The DataTypeService class implements IDataTypeService. It provides access to operations involving IDataType. -```csharp -public void ConfigureServices(IServiceCollection services) -{ -#pragma warning disable IDE0022 // Use expression body for methods - services.AddUmbraco(_env, _config) - .AddBackOffice() - .AddWebsite() - .AddComposers() - .AddDontShoutNotifications() - .Build(); -#pragma warning restore IDE0022 // Use expression body for methods - -} -``` - -Now, your handler will handle all the notifications you registered in your extension method. - -## Async Notification Handler - -If you need to do anything asynchronously when handling a notification, you can achieve this using the `INotificationAsyncHandler`. +Below you can find a list of the most common DataTypeService object notifications. -### Notification handler +* [DataTypeSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeSavingNotification.html) -Create an asynchronous handler by implementing the `INotificationAsyncHandler`: +* [DataTypeSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeSavedNotification.html) -```csharp -public class ContentDeletedHandler : INotificationAsyncHandler -{ - public async Task HandleAsync(ContentDeletedNotification notification, CancellationToken cancellationToken) - { - // await anything - await Task.Delay(1000); - } -} -``` - -### Notification registration - -When using the `INotificationAsyncHandler`, register it using the `IUmbracoBuilder` and the `AddNotificationAsyncHandler` extension method. This can be done in the Startup class or with a composer. - -#### Registering notification async handlers in the startup class - -Register your notification async handler to the `IUmbracoBuilder` in the Startup class: - -```csharp -public void ConfigureServices(IServiceCollection services) -{ - services.AddUmbraco(_env, _config) - .AddBackOffice() - .AddWebsite() - .AddComposers() - .AddNotificationAsyncHandler() - .Build(); -} -``` - -#### Registering notification async handlers in a composer +* [DataTypeDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeDeletingNotification.html) -If you do not have access to the Startup class, use a composer instead: - -```csharp -public class NotificationHandlersComposer : IComposer -{ - public void Compose(IUmbracoBuilder builder) - { - builder.AddNotificationAsyncHandler(); - } -} -``` - -## Content, Media, and Member notifications - -* See [ContentService Notifications](contentservice-notifications.md) for a list of the ContentService object notifications. -* See [MediaService Notifications](mediaservice-notifications.md) for a list of the MediaService object notifications. -* See [MemberService Notifications](memberservice-notifications.md) for a list of the MemberService object notifications. - -## Other notifications - -* See [ContentTypeService Notifications](contentypeservice-notifications.md) for a list of the ContentTypeService object notifications. -* See [MediaTypeService Notifications](mediatypeservice-notifications.md) for a list of the MediaTypeService object notifications. -* See [MemberTypeService Notifications](membertypeservice-notifications.md) for a list of the MemberTypeService object notifications. -* See [DataTypeService Notifications](datatypeservice-notifications.md) for a list of the DataTypeService object notifications. -* See [FileService Notifications](fileservice-notifications.md) for a list of the FileService object notifications. -* See [LocalizationService Notifications](localizationservice-notifications.md) for a list of the LocalizationService object notifications. - -## Tree notifications +* [DataTypeDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeDeletedNotification.html) + +* [DataTypeMovingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeMovingNotification.html) + +* [DataTypeMovedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DataTypeMovedNotification.html) + +
    + +
    + +**FileService** Notifications + +The FileService class implements IFileService. It provides access to operations involving IFile objects like scripts, stylesheets and templates. + +Below you can find a list of the most common FileService object notifications. + +* [TemplateSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.TemplateSavingNotification.html) + +* [TemplateSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.TemplateSavedNotification.html) + +* [ScriptSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ScriptSavingNotification.html) + +* [ScriptSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ScriptSavedNotification.html) + +* [StylesheetSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetSavingNotification.html) + +* [StylesheetSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetSavedNotification.html) + +* [TemplateDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.TemplateDeletingNotification.html) + +* [TemplateDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.TemplateDeletedNotification.html) + +* [ScriptDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ScriptDeletingNotification.html) + +* [ScriptDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ScriptDeletedNotification.html) + +* [StylesheetDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetDeletingNotification.html) + +* [StylesheetDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.StylesheetDeletedNotification.html) + +
    + +
    + +**LocalizationService** Notifications + +The LocalizationService class implements ILocalizationService. It provides access to operations involving Language and DictionaryItem. + +Below you can find a list of the most common LocalizationService object notifications. + +* [LanguageSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.LanguageSavingNotification.html) + +* [LanguageSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.LanguageSavedNotification.html) + +* [DictionaryItemSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemSavingNotification.html) + +* [DictionaryItemSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemSavedNotification.html) + +* [LanguageDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.LanguageDeletingNotification.html) + +* [LanguageDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.LanguageDeletedNotification.html) + +* [DictionaryItemDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemDeletingNotification.html) + +* [DictionaryItemDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.DictionaryItemDeletedNotification.html) + +
    + +
    + +**CacheRefresher** Notifications + +Below you can find a list of the most common CacheRefresher object notifications. + +* [ContentCacheRefresherNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.ContentCacheRefresherNotification.html) + +* [MediaCacheRefresherNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MediaCacheRefresherNotification.html) + +* [MemberCacheRefresherNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.MemberCacheRefresherNotification.html) + +* [UserCacheRefresherNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.UserCacheRefresherNotification.html) + +
    + +
    + +**RelationService** Notifications + +Below you can find a list of the most common RelationService object notifications. + +The RelationService provides access to operations involving IRelation and IRelationType, and publishes the following relation notifications: + +* [RelationSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.RelationSavingNotification.html) + +* [RelationSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.RelationSavedNotification.html) + +* [RelationDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.RelationDeletingNotification.html) + +* [RelationDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.RelationDeletedNotification.html) + +* [RelationTypeSavingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeSavingNotification.html) + +* [RelationTypeSavedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeSavedNotification.html) + +* [RelationTypeDeletingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeDeletingNotification.html) + +* [RelationTypeDeletedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.RelationTypeDeletedNotification.html) + +
    + +
    + +**UmbracoApplicationLifetime** Notifications + +Represents an Umbraco application lifetime (starting, started, stopping, stopped) notification. + +Below you can find a list of the most common UmbracoApplicationLifetime object notifications. + +* [UmbracoApplicationStartingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStartingNotification.html) + +* [UmbracoApplicationStartedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStartedNotification.html) + +* [UmbracoApplicationStoppingNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStoppingNotification.html) + +* [UmbracoApplicationStoppedNotification](https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Notifications.UmbracoApplicationStoppedNotification.html) + +
    + +### Tree notifications See [Tree Notifications](../../extending/section-trees/) for a list of the tree notifications. -## Editor Model Notifications +### Editor Model Notifications -See [EditorModel Notifications](editormodel-notifications/) for a list of the EditorModel events +See [EditorModel Notifications](editormodel-notifications/) for a list of the EditorModel events. {% hint style="info" %} Useful for manipulating the model before it is sent to an editor in the backoffice. It could be used to set a default value of a property on a new document. @@ -213,3 +365,23 @@ Useful for manipulating the model before it is sent to an editor in the backoffi ## Creating and publishing your own custom notifications Umbraco uses notifications to allow people to hook into different workflow processes. This notification pattern is extensible, allowing you to create and publish custom notifications, and other people to observe and hook into your custom processes. This approach can be very useful when creating Umbraco packages. For more information on how you create and publish your own notifications, see the [creating and publishing notifications](creating-and-publishing-notifications.md) article. + +## Samples + +Below you can find some articles with some examples using Notifications. + +* [CacheRefresher Notification](./cacherefresher-notifications.md) + +* [ContentService Notifications](./contentservice-notifications.md) + +* [Determining if an entity is new](./determining-new-entity.md) + +* [Hot vs. cold restarts](./hot-vs-cold-restarts.md) + +* [MediaService Notifications](./mediaservice-notifications.md) + +* [MemberService Notifications](./memberservice-notifications.md) + +* [Sending Allowed Children Notification](./sendingallowedchildrennotifications.md) + +* [Umbraco Application Lifetime Notifications](./umbracoapplicationlifetime-notifications.md) diff --git a/12/umbraco-cms/reference/notifications/cacherefresher-notifications.md b/12/umbraco-cms/reference/notifications/cacherefresher-notifications.md index d36564ad6d0..da54f65f7a6 100644 --- a/12/umbraco-cms/reference/notifications/cacherefresher-notifications.md +++ b/12/umbraco-cms/reference/notifications/cacherefresher-notifications.md @@ -1,3 +1,7 @@ +--- +description: Example of how to use a CacheRefresher Notification +--- + # CacheRefresher Notifications Before starting with cache refresher notifications it's a good idea to ensure you need to use them. If you want to react to changes in content, for instance, there's no real reason to use these notifications. This is due to the [content service notifications](contentservice-notifications.md) being easier to work with. If you need to react to changes in the cache, then these are the notifications for you. @@ -105,10 +109,3 @@ public class ContentCacheRefresherExample : INotificationHandler
  • object MessageObject
  • MessageType MessageType
  • |

    Published when the content cache has been updated.
    MessageObject: The refresher payload.
    MessageType: The type of cache refresher message.

    | -| MediaCacheRefresherNotification |
    • object MessageObject
    • MessageType MessageType
    |

    Published when the media cache has been updated.
    MessageObject: The refresher payload.
    MessageType: The type of cache refresher message.

    | -| MemberCacheRefresherNotification |
    • object MessageObject
    • MessageType MessageType
    |

    Published when the member cache has been updated.
    MessageObject: The refresher payload.
    MessageType: The type of cache refresher message.

    | -| UserCacheRefresherNotification |
    • object MessageObject
    • MessageType MessageType
    |

    Published when the user cache has been updated.
    MessageObject: The refresher payload.
    MessageType: The type of cache refresher message.

    | diff --git a/12/umbraco-cms/reference/notifications/contentservice-notifications.md b/12/umbraco-cms/reference/notifications/contentservice-notifications.md index 71aca8fd72e..779c0cb6fc2 100644 --- a/12/umbraco-cms/reference/notifications/contentservice-notifications.md +++ b/12/umbraco-cms/reference/notifications/contentservice-notifications.md @@ -1,3 +1,7 @@ +--- +description: Find out more about ContentService Notifications and explore some example of how to use it +--- + # ContentService Notifications The ContentService class is the most commonly used type when extending Umbraco using notifications. ContentService implements IContentService. It provides access to operations involving IContent. @@ -33,35 +37,6 @@ public class DontShout : INotificationHandler } ``` -## Notifications - -| Notification | Members | Description | -| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| ContentSavingNotification |
    • IEnumerable<IContent> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when the IContentService.Save is called in the API.
    NOTE: It can be skipped if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    SavedEntities: The collection of IContent objects being saved.
    NOTE: If the entity is brand new then HasIdentity will equal false.

    | -| ContentSavedNotification |
    • IEnumerable<IContent> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when IContentService.Save is called in the API and after data has been persisted.
    NOTE: It can be skipped if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    NOTE: See here on how to determine if the entity is brand new
    SavedEntities: The saved collection of IContent objects.

    | -| ContentPublishingNotification |
    • IEnumerable<IContent> PublishedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when IContentService.Publishing is called in the API.
    NOTE: It can be skipped if the parameter "raiseEvents" is set to false during the Publish method call (true by default).
    NOTE: If the entity is brand new then HasIdentity will equal false.
    PublishedEntities: The collection of IContent objects being published.

    | -| ContentPublishedNotification |
    • IEnumerable<IContent> PublishedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when IContentService.Publish is called in the API and after data has been published.
    NOTE: It can be skipped if the parameter "raiseEvents" is set to false during the Publish method call (true by default).
    NOTE: See here on how to determine if the entity is brand new
    PublishedEntities: The published collection of IContent objects.

    | -| ContentUnpublishingNotification |
    • IEnumerable<IContent> UnpublishedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when IContentService.UnPublishing is called in the API.
    UnpublishedEntities: The collection of IContent being unpublished.

    | -| ContentUnpublishedNotification |
    • IEnumerable<IContent> UnpublishedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when IContentService.UnPublish is called in the API and after data has been unpublished.
    UnpublishedEntities: The collection of unpublished IContent.

    | -| ContentCopyingNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    • IContent Original
    • IContent Copy
    • int ParentId
    |

    Published when IContentService.Copy is called in the API.
    The notification is published after a copy object has been created and had its parentId updated and its state has been set to unpublished.

    1. Original: Gets the original IContent object.
    2. Copy: Gets the IContent object being copied.
    3. ParentId: Gets the Id of the parent of the IContent being copied.
    | -| ContentCopiedNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • IContent Original
    • IContent Copy
    • int ParentId
    • bool RelateToOriginal
    |

    Published when IContentService.Copy is called in the API.
    The notification is published after the content object has been copied.

    1. Original: Gets the original IContent object.
    2. Copy: Gets the IContent object being copied.
    3. ParentId: Gets the Id of the parent of the IContent being copied.
    4. RelateToOriginal: Boolean indicating whether the copy was related to the original
    | -| ContentMovingNotification |
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when IContentService.Move is called in the API.
    NOTE: If the target parent is the Recycle bin, this notification is never published. Try the ContentMovingToRecycleBinNotification instead.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IContent object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    | -| ContentMovedNotification |
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when IContentService.Move is called in the API. The notification is published after the content object has been moved.
    NOTE: If the target parent is the Recycle bin, this notification is never published. Try the ContentMovedToRecycleBinNotification instead.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IContent object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    | -| ContentMovingToRecycleBinNotification |
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.MoveToRecycleBin is called in the API.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IContent object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the RecycleBin
    | -| ContentMovedToRecycleBinNotification |
    • IEnumerable<MoveEventInfo<IContent>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.MoveToRecycleBin is called in the API. Is published after the content has been moved to the RecycleBin
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IContent object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the RecycleBin
    | -| ContentDeletingNotification |
    • IEnumerable<IContent> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.DeleteContentOfType, ContentService.Delete, ContentService.EmptyRecycleBin are called in the API.
    DeletedEntities: Gets the collection of IContent objects being deleted.

    | -| ContentDeletedNotification |
    • IEnumerable<IContent> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.Delete, ContentService.EmptyRecycleBin are called in the API, and the entity has been deleted.
    DeletedEntities: Gets the collection of deleted IContent objects.

    | -| ContentDeletingVersionsNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    • int Id
    • int SpecificVersion
    • DateTime DateToRetain
    • bool DeletePriorVersions
    |

    Published when ContentService.DeleteVersion, ContentService.DeleteVersions are called in the API.

    1. Id: Gets the id of the IContent object being deleted.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersion: Gets the id of the IContent object version being deleted.
    4. DeletePriorVersions: False by default
    | -| ContentDeletedVersionsNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • int Id
    • int SpecificVersion
    • DateTime DateToRetain
    • bool DeletePriorVersions
    |

    Published when ContentService.DeleteVersion, ContentService.DeleteVersions are called in the API, and the version has been deleted.

    1. Id: Gets the id of the IContent object being deleted.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersion: Gets the id of the IContent object version being deleted.
    4. DeletePriorVersions: False by default
    | -| ContentRollingBackNotification |
    • IContent Entity
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.Rollback is called in the API.
    Entity: Gets the IContent object being rolled back.

    | -| ContentRolledBackNotification |
    • IContent Entity
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.Rollback is called in the API, after the content has been rolled back.
    Entity: Gets the IContent object being rolled back.

    | -| ContentSendingToPublishNotification |
    • IContent Entity
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.SendToPublication is called in the API.
    Entity: Gets the IContent object being sent to publish.

    | -| ContentSentToPublishNotification |
    • IContent Entity
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.SendToPublication is called in the API, after the entity has been sent to publication.
    Entity: Gets the IContent object being sent to publish.

    | -| ContentEmptyingRecycleBinNotification |
    • IEnumerable<IContent> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when ContentService.EmptyRecycleBin is called in the API.
    DeletedEntities: The collection of IContent objects being deleted.

    | -| ContentEmptiedRecycleBinNotification |
    • IEnumerable<IContent> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.EmptyRecycleBin is called in the API, after the RecycleBin has been emptied.
    DeletedEntities: The collection of deleted IContent object.

    | -| ContentSavedBlueprintNotification |
    • IContent SavedBlueprint
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.SavedBlueprint is called in the API.
    SavedBlueprint: Gets the saved blueprint IContent object

    | -| ContentDeletedBlueprintNotification |
    • IEnumerable<IContent> DeletedBlueprints
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when ContentService.DeletedBlueprint is called in the API.
    DeletedBlueprints: The collection of deleted blueprint IContent

    | - ### Variants and Notifications Umbraco V8 introduced the concept of Variants for Document Types, initially to allow different language variants of particular properties within a Document Type to be edited/translated based on the languages configured in your instance of Umbraco. @@ -112,10 +87,10 @@ When handling the Unpublishing notification, it might not work how you would exp ```csharp public void Handle(ContentUnpublishingNotification notification) { - foreach (var unPublishedEntity in notification.UnpublishedEntities) - { - // complete unpublishing of entity, all cultures - } + foreach (var unPublishedEntity in notification.UnpublishedEntities) + { + // complete unpublishing of entity, all cultures + } } ``` diff --git a/12/umbraco-cms/reference/notifications/mediaservice-notifications.md b/12/umbraco-cms/reference/notifications/mediaservice-notifications.md index 2263eeb8eb6..050e0b90027 100644 --- a/12/umbraco-cms/reference/notifications/mediaservice-notifications.md +++ b/12/umbraco-cms/reference/notifications/mediaservice-notifications.md @@ -1,3 +1,7 @@ +--- +description: Example of how to use a MediaService Notification +--- + # MediaService Notifications The MediaService class implements IMediaService. It provides access to operations involving IMedia. @@ -76,21 +80,6 @@ namespace MyProject ![image](https://github.com/umbraco/UmbracoDocs/assets/6904597/67696298-2710-4aeb-bd0a-33c6d8414216) -## Events - -| Notification | Members | Description | -| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| MediaSavingNotification |
    • IEnumerable<IMedia> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MediaService.Save is called in the API.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    SavedEntities: Gets the collection of IMedia objects being saved.

    | -| MediaSavedNotification |
    • IEnumerable<IMedia> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MediaService.Save is called in the API and after the data has been persisted.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    SavedEntities: Gets the saved collection of IMedia objects.

    | -| MediaMovingNotification |
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MediaService.Move is called in the API.
    NOTE: If the target parent is the Recycle bin, this notification is never published. Try the MediaMovingToRecycleBinNotification instead.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IMedia object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    | -| MediaMovedNotification |
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MediaService.Move is called in the API. The event is fired after the media object has been moved.
    NOTE: If the target parent is the Recycle bin, this notification is never published. Try the MediaMovedToRecycleBinNotification instead.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IMedia object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the parent the entity will have after it has been moved
    | -| MediaMovingToRecycleBinNotification |
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MediaService.MoveToRecycleBin is called in the API.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IMedia object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the RecycleBin
    | -| MediaMovedToRecycleBinNotification |
    • IEnumerable<MoveEventInfo<IMedia>> MoveInfoCollection
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MediaService.MoveToRecycleBin is called in the API, after the media object has been moved to the RecycleBin.
    MoveInfoCollection will for each moving entity provide:

    1. Entity: Gets the IMedia object being moved
    2. OriginalPath: The original path the entity is moved from
    3. NewParentId: Gets the Id of the RecycleBin
    | -| MediaDeletingNotification |
    • IEnumerable<IMedia> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MediaService.DeleteMediaOfType, MediaService.Delete, MediaService.EmptyRecycleBin are called in the API.
    DeletedEntities: Gets the collection of IMedia objects being deleted.

    | -| MediaDeletedNotification |
    • IEnumerable<IMedia> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MediaService.Delete, MediaService.EmptyRecycleBin are called in the API, after the media has been deleted.
    DeletedEntities: Gets the collection of deleted IMedia objects.

    | -| MediaDeletingVersionsNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    • int Id
    • int SpecificVersion
    • DateTime DateToRetain
    • bool DeletePriorVersions
    |

    Published when MediaService.DeleteVersion, MediaService.DeleteVersions are called in the API.

    1. Id: Gets the id of the IMedia object being deleted.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersion: Gets the id of the IMedia object version being deleted.
    4. DeletePriorVersions: False by default
    | -| MediaDeletedVersionsNotification |
    • EventMessages Messages
    • IDictionary<string,object> State
    • int Id
    • int SpecificVersion
    • DateTime DateToRetain
    • bool DeletePriorVersions
    |

    Published when MediaService.DeleteVersion, MediaService.DeleteVersions are called in the API, after the media version has been deleted

    1. Id: Gets the id of the deleted IMedia object.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersion: Gets the id of the deleted IMedia object version.
    4. DeletePriorVersions: False by default
    | - ### What happened to Creating and Created events? Both the MediaService.Creating and MediaService.Created events have been obsoleted. Because of this, these were not moved over to notifications, and no longer exist. Why? Because these events were not guaranteed to trigger and therefore should not have been used. This is because these events _only_ triggered when the MediaService.CreateMedia method was used which is an entirely optional way to create media entities. It is also possible to construct a new media item - which is generally the preferred and consistent way - and therefore the Creating/Created events would not execute when constructing media that way. diff --git a/12/umbraco-cms/reference/notifications/memberservice-notifications.md b/12/umbraco-cms/reference/notifications/memberservice-notifications.md index 2469800436d..1f5df2d9069 100644 --- a/12/umbraco-cms/reference/notifications/memberservice-notifications.md +++ b/12/umbraco-cms/reference/notifications/memberservice-notifications.md @@ -1,3 +1,7 @@ +--- +description: Example of how to use a MemberService Notification +--- + # MemberService Notifications The MemberService implements IMemberService and provides access to operations involving IMember. @@ -7,7 +11,7 @@ The MemberService implements IMemberService and provides access to operations in ```csharp using Microsoft.Extensions.Logging; using Umbraco.Cms.Core.Events; -using Umbraco.Cms.Core.Services.Notifications; +using Umbraco.Cms.Core.Notifications; namespace MySite; @@ -30,12 +34,3 @@ public class MemberNotificationHandler : INotificationHandler
  • IEnumerable<IMember> SavedEntities
  • EventMessages Messages
  • IDictionary<string,object> State
  • bool Cancel
  • |

    Published when MemberService.Saving is called in the API.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    SavedEntities: Gets the collection of IMember objects being saved.

    | -| MemberSavedNotification |
    • IEnumerable<IMember> SavedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MemberService.Save is called in the API and after data has been persisted.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    NOTE: See here on how to determine if the entity is brand new
    SavedEntities: Gets the saved collection of IMember objects.

    | -| MemberDeletingNotification |
    • IEnumerable<IMember> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    • bool Cancel
    |

    Published when MemberService.Delete, and MemberService.DeleteMembersOfType are called in the API.
    DeletedEntities: Gets the collection of IMember objects being deleted.

    | -| MemberDeletedNotification |
    • IEnumerable<IMember> DeletedEntities
    • EventMessages Messages
    • IDictionary<string,object> State
    |

    Published when MemberService.Delete, and MemberService.DeleteMembersOfType are called in the API, after the members has been deleted.
    DeletedEntities: Gets the collection of deleted IMember objects.

    | -| AssignedMemberRolesNotification |
    • string[] Roles
    • int[] MemberIds
    |

    Published when MemberService.AssignRoles, and MemberService.ReplaceRoles are called in the API.

    1. Roles: Collection of role names being assigned.
    2. MemberIds: Collection of Ids of the members the roles are being assigned to.
    | -| RemovedMemberRolesNotification |
    • string[] Roles
    • int[] MemberIds
    |

    Published when MemberService.DissociateRoles are being called in the API.

    1. Roles: Collection of role names being removed.
    2. MemberIds: Collection of Ids of the members the roles are being removed from.
    | diff --git a/12/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md b/12/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md index fbe3360f489..c1b26bcff5f 100644 --- a/12/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md +++ b/12/umbraco-cms/reference/notifications/umbracoapplicationlifetime-notifications.md @@ -49,12 +49,3 @@ public class UmbracoApplicationNotificationHandler : INotificationHandler _logger.LogInformation("{Type} - {IsRestarting}", notification.GetType().Name, isRestarting); } ``` - -## Notifications - -| Notification | Members | Description | -| -------------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| UmbracoApplicationStartingNotification |
    • RuntimeLevel RuntimeLevel
    • bool IsRestarting
    |

    Triggered when the application is starting after all IComponents are initialized but before any incoming requests are accepted.

    1. RuntimeLevel: Gets the runtime level.
    2. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    | -| UmbracoApplicationStartedNotification |
    • bool IsRestarting
    |

    Triggered when the application has fully started and is accepting incoming requests.

    1. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    | -| UmbracoApplicationStoppingNotification |
    • bool IsRestarting
    |

    Triggered when the application is performing a graceful shutdown after all IComponents are terminated.

    1. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    | -| UmbracoApplicationStoppedNotification |
    • bool IsRestarting
    |

    Triggered when the application has performed a graceful shutdown.

    1. IsRestarting: Gets a value indicating whether Umbraco is restarting (for example after an install or upgrade).
    | diff --git a/13/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md b/13/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md index b3a7a9d877e..eeaf242650a 100644 --- a/13/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md +++ b/13/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md @@ -68,7 +68,7 @@ public class SendingAllowedChildrenNotificationHandler : INotificationHandler Date: Fri, 12 Apr 2024 09:21:24 +0200 Subject: [PATCH 4/5] Update 10/umbraco-cms/reference/notifications/README.md --- 10/umbraco-cms/reference/notifications/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10/umbraco-cms/reference/notifications/README.md b/10/umbraco-cms/reference/notifications/README.md index 9c7178b31e9..bbed1803f25 100644 --- a/10/umbraco-cms/reference/notifications/README.md +++ b/10/umbraco-cms/reference/notifications/README.md @@ -364,7 +364,7 @@ Useful for manipulating the model before it is sent to an editor in the backoffi ## Creating and publishing your own custom notifications -Umbraco uses notifications to allow people to hook into different workflow processes. This notification pattern is extensible, allowing you to create and publish custom notifications, and other people to observe and hook into your custom processes. This approach can be very useful when creating Umbraco packages. For more information on how you create and publish your own notifications, see the [creating and publishing notifications](creating-and-publishing-notifications.md) article. +Umbraco uses notifications to allow people to hook into different workflow processes. This notification pattern is extensible, allowing you to create and publish custom notifications, and other people to observe and hook into your custom processes. This approach can be useful when creating Umbraco packages. For more information on how you create and publish your own notifications, see the [creating and publishing notifications](creating-and-publishing-notifications.md) article. ## Samples From 5285a7c72df3869fb443de352652371845adbfae Mon Sep 17 00:00:00 2001 From: "Alina-Magdalena Tincas (Umbraco HQ)" Date: Fri, 12 Apr 2024 09:37:39 +0200 Subject: [PATCH 5/5] leftover --- 10/umbraco-cms/SUMMARY.md | 16 +- .../notifications/notification-handler.md | 111 +++++++++++ 12/umbraco-cms/SUMMARY.md | 16 +- .../reference/dive-into-the-code.md | 2 +- .../notifications/notification-handler.md | 176 ++++++++++++++++++ 5 files changed, 298 insertions(+), 23 deletions(-) create mode 100644 10/umbraco-cms/reference/notifications/notification-handler.md create mode 100644 12/umbraco-cms/reference/notifications/notification-handler.md diff --git a/10/umbraco-cms/SUMMARY.md b/10/umbraco-cms/SUMMARY.md index 341996326b7..cfab0c9d705 100644 --- a/10/umbraco-cms/SUMMARY.md +++ b/10/umbraco-cms/SUMMARY.md @@ -293,19 +293,13 @@ * [PDF indexes and multisearchers](reference/searching/examine/pdfindex-multisearcher.md) * [quick-start](reference/searching/examine/quick-start.md) * [Using Notifications](reference/notifications/README.md) - * [CacheRefresher Notifications](reference/notifications/cacherefresher-notifications.md) - * [ContentService Notifications](reference/notifications/contentservice-notifications.md) - * [ContentTypeService Notifications](reference/notifications/contentypeservice-notifications.md) + * [Notification Handler](reference/notifications/notification-handler.md) + * [CacheRefresher Notifications Example](reference/notifications/cacherefresher-notifications.md) + * [ContentService Notifications Example](reference/notifications/contentservice-notifications.md) * [Creating And Publishing Notifications](reference/notifications/creating-and-publishing-notifications.md) - * [DataTypeService Notifications](reference/notifications/datatypeservice-notifications.md) * [Determining if an entity is new](reference/notifications/determining-new-entity.md) - * [FileService Notifications](reference/notifications/fileservice-notifications.md) - * [LocalizationService Events](reference/notifications/localizationservice-notifications.md) - * [MediaService Notifications](reference/notifications/mediaservice-notifications.md) - * [MediaTypeService Notifications](reference/notifications/mediatypeservice-notifications.md) - * [MemberService Notifications](reference/notifications/memberservice-notifications.md) - * [MemberTypeService Notifications](reference/notifications/membertypeservice-notifications.md) - * [RelationService Notifications](reference/notifications/relationservice-notifications.md) + * [MediaService Notifications Example](reference/notifications/mediaservice-notifications.md) + * [MemberService Notifications Example](reference/notifications/memberservice-notifications.md) * [Sending Allowed Children Notification](reference/notifications/sendingallowedchildrennotifications.md) * [Umbraco Application Lifetime Notifications](reference/notifications/umbracoapplicationlifetime-notifications.md) * [EditorModel Notifications](reference/notifications/editormodel-notifications/README.md) diff --git a/10/umbraco-cms/reference/notifications/notification-handler.md b/10/umbraco-cms/reference/notifications/notification-handler.md new file mode 100644 index 00000000000..7b2fb3f17cc --- /dev/null +++ b/10/umbraco-cms/reference/notifications/notification-handler.md @@ -0,0 +1,111 @@ +--- +description: Learn about notification handlers lifetime, async notification handler and how to register the notification handlers. +--- + +# Notification handlers lifetime + +It's important to note that the handlers you create and register to receive notifications will be transient, this means that they will be initialized every time they receive a notification, so you cannot rely on them having a specific state based on previous notifications. For instance, you cannot create a list in a handler and add something when a notification is received, and then check if that list contains what you added in an earlier notification, that list will always be empty because the object has just been initialized. + +If you need persistence between notifications, we recommend that you move that functionality into a service or similar, and register it with the DI container, and then inject that into your handler. + +As previously mentioned a lot of notifications exist in pairs, with a "before" and "after" notification, there may be cases where you want to add some information to the "before" notification, which will then be available to your "after" notification handler, in order to support this, the notification "pairs" are stateful. This means that the notifications contain a dictionary that is shared between the "before" and "after" notification that you can add values to, and later get them from like this: + +```C# +public void Handle(TemplateSavingNotification notification) +{ + notification.State["SomeKey"] = "Some Value Relevant to the \"after\" notification handler"; +} + + +public void Handle(TemplateSavedNotification notification) +{ + var valueFromSaving = notification.State["SomeKey"]; +} +``` + +# Registering notification handlers + +Once you've made your notification handlers you need to register them with the `AddNotificationHandler` extension method on the `IUmbracoBuilder`, so they're run whenever a notification they subscribe to is published. There are two ways to do this: In the Startup class, if you're making handlers for your site, or a composer if you're a package developer subscribing to notifications. + +#### Registering notification handlers in the startup class + +In the Startup class register your notification handler in the `ConfigureServices` after `AddComposers()` but before `Build()`: + +```C# +public void ConfigureServices(IServiceCollection services) +{ +#pragma warning disable IDE0022 // Use expression body for methods + services.AddUmbraco(_env, _config) + .AddBackOffice() + .AddWebsite() + .AddComposers() + .AddNotificationHandler() + .Build(); +#pragma warning restore IDE0022 // Use expression body for methods + +} +``` + +The extension method takes two generic type parameters, the first `ContentPublishingNotification` is the notification you wish to subscribe to, the second `DontShout` is the class that handles the notification. This class must implement `INotificationHandler<>` with the type of notification it handles as the generic type parameter, in this case, the DontShout class definition looks like this: + +```C# +public class DontShout : INotificationHandler +``` + +For the full handler implementation see [ContentService Notifications](contentservice-notifications.md). + +## Registering notification handlers in a composer + +If you're writing a package for Umbraco you won't have access to the Startup class, you can instead use a composer which gives you access to the `IUmbracoBuilder`, the rest is the same as when doing it in the Startup class: + +```C# +public class DontShoutComposer : IComposer +{ + public void Compose(IUmbracoBuilder builder) + { + builder.AddNotificationHandler(); + } +} +``` + +## Registering many notification handlers + +You may want to subscribe to a lot of notifications, in this case, your `ConfigureServices` method or composer might end up being quite cluttered. You can avoid this by creating your own `IUmbracoBuilder` extension method for your events, keeping everything neatly wrapped up in one place, such an extension method can look like this: + +```C# +using Umbraco.Cms.Core.DependencyInjection; +using Umbraco.Cms.Core.Services.Notifications; + +namespace MySite +{ + public static class UmbracoBuilderNotificationExtensions + { + public static IUmbracoBuilder AddDontShoutNotifications(this IUmbracoBuilder builder) + { + builder + .AddNotificationHandler() + .AddNotificationHandler() + .AddNotificationHandler(); + + return builder; + } + } +} +``` + +You can then register all these notifications by calling `AddDontShoutNotifications` in `ConfigureServices` or your composer, just like you would `AddNotificationHandler`: + +```C# +public void ConfigureServices(IServiceCollection services) +{ +#pragma warning disable IDE0022 // Use expression body for methods + services.AddUmbraco(_env, _config) + .AddBackOffice() + .AddWebsite() + .AddComposers() + .AddDontShoutNotifications() + .Build(); +#pragma warning restore IDE0022 // Use expression body for methods + +} +``` diff --git a/12/umbraco-cms/SUMMARY.md b/12/umbraco-cms/SUMMARY.md index 5485b917dcb..a50548600e2 100644 --- a/12/umbraco-cms/SUMMARY.md +++ b/12/umbraco-cms/SUMMARY.md @@ -301,19 +301,13 @@ * [PDF indexes and multisearchers](reference/searching/examine/pdfindex-multisearcher.md) * [quick-start](reference/searching/examine/quick-start.md) * [Using Notifications](reference/notifications/README.md) - * [CacheRefresher Notifications](reference/notifications/cacherefresher-notifications.md) - * [ContentService Notifications](reference/notifications/contentservice-notifications.md) - * [ContentTypeService Notifications](reference/notifications/contentypeservice-notifications.md) + * [Notification Handler](reference/notifications/notification-handler.md) + * [CacheRefresher Notifications Example](reference/notifications/cacherefresher-notifications.md) + * [ContentService Notifications Example](reference/notifications/contentservice-notifications.md) * [Creating And Publishing Notifications](reference/notifications/creating-and-publishing-notifications.md) - * [DataTypeService Notifications](reference/notifications/datatypeservice-notifications.md) * [Determining if an entity is new](reference/notifications/determining-new-entity.md) - * [FileService Notifications](reference/notifications/fileservice-notifications.md) - * [LocalizationService Events](reference/notifications/localizationservice-notifications.md) - * [MediaService Notifications](reference/notifications/mediaservice-notifications.md) - * [MediaTypeService Notifications](reference/notifications/mediatypeservice-notifications.md) - * [MemberService Notifications](reference/notifications/memberservice-notifications.md) - * [MemberTypeService Notifications](reference/notifications/membertypeservice-notifications.md) - * [RelationService Notifications](reference/notifications/relationservice-notifications.md) + * [MediaService Notifications Example](reference/notifications/mediaservice-notifications.md) + * [MemberService Notifications Example](reference/notifications/memberservice-notifications.md) * [Sending Allowed Children Notification](reference/notifications/sendingallowedchildrennotifications.md) * [Umbraco Application Lifetime Notifications](reference/notifications/umbracoapplicationlifetime-notifications.md) * [EditorModel Notifications](reference/notifications/editormodel-notifications/README.md) diff --git a/12/umbraco-cms/reference/dive-into-the-code.md b/12/umbraco-cms/reference/dive-into-the-code.md index 9f5697838af..37436f42388 100644 --- a/12/umbraco-cms/reference/dive-into-the-code.md +++ b/12/umbraco-cms/reference/dive-into-the-code.md @@ -10,7 +10,7 @@ The developers' Reference section primarily consists of API references of the di The section also includes documentation about the different configuration options, security, advanced templating, and searching. -
    ConfigurationMost configuration in Umbraco CMS is handled via the appSettings.json file.configurationsetup-image.png
    TemplatingWork with MVC views and Razor templates to build the frontend for your Umbraco CMS website.templatingdesign.png
    Querying & ModelsEverything you need to extend your templates with filters, models, and more advanced queries.queryingdatap-image.png
    Routing and ControllersDive into working with routers and controllers for customizing your Umbraco CMS even further.routingcontrollers-image.png
    SecurityFind everything you need related to keeping your Umbraco CMS website secure.securitysecurity-imag.png
    SearchingLearn about Examine and Lucene which are tools utilized in Umbraco for the search functionality.searchingsearching-image.png
    NotificationsLearn how to use notifications to hook into the workflow processes for the backoffice.fileservice-notifications.mdnotifications-image.png
    CachingLearn how to implement caching features in the Umbraco CMS application.cachecaching-image.png
    API DocumentationDive into the deep end and start exploring the different sections of the Umbraco CMS API.api-documentation.mdapi-docs-image.png
    +
    ConfigurationMost configuration in Umbraco CMS is handled via the appSettings.json file.configurationsetup-image.png
    TemplatingWork with MVC views and Razor templates to build the frontend for your Umbraco CMS website.templatingdesign.png
    Querying & ModelsEverything you need to extend your templates with filters, models, and more advanced queries.queryingdatap-image.png
    Routing and ControllersDive into working with routers and controllers for customizing your Umbraco CMS even further.routingcontrollers-image.png
    SecurityFind everything you need related to keeping your Umbraco CMS website secure.securitysecurity-imag.png
    SearchingLearn about Examine and Lucene which are tools utilized in Umbraco for the search functionality.searchingsearching-image.png
    NotificationsLearn how to use notifications to hook into the workflow processes for the backoffice.Notificationsnotifications-image.png
    CachingLearn how to implement caching features in the Umbraco CMS application.cachecaching-image.png
    API DocumentationDive into the deep end and start exploring the different sections of the Umbraco CMS API.api-documentation.mdapi-docs-image.png
    ## Also in this section diff --git a/12/umbraco-cms/reference/notifications/notification-handler.md b/12/umbraco-cms/reference/notifications/notification-handler.md new file mode 100644 index 00000000000..3bb682f3864 --- /dev/null +++ b/12/umbraco-cms/reference/notifications/notification-handler.md @@ -0,0 +1,176 @@ +--- +description: Learn about notification handlers lifetime, async notification handler and how to register the notification handlers. +--- + +# Notification handlers lifetime + +It's important to know that the handlers you create and register to receive notifications will be **transient**. This means that they will be initialized every time they receive a notification. You can therefore not rely on them having a specific state based on previous notifications. + +As an example, you cannot do the following: + +1. Create a list in a handler. +2. Add something when a notification is received. +3. Check if that list contains what you added in an earlier notification. + +When following the steps above, the list will always be empty because the object has only been initialized. + +If you need persistence between notifications, we recommend you move that functionality into a service or similar. You can then register it with the DI container, and inject it into your handler. + +As previously mentioned, many notifications exist in pairs, with a "before" and "after" notification. There may be cases where you want to add some information to the "before" notification, which will then be available to your "after" notification handler. In order to support this, the notification "pairs" are **stateful**. This means the notifications contain a dictionary that is shared between the "before" and "after" notifications. You can add values to the dictionary, and later retrieve them like this: + +```csharp +public void Handle(TemplateSavingNotification notification) +{ + notification.State["SomeKey"] = "Some Value Relevant to the \"after\" notification handler"; +} + + +public void Handle(TemplateSavedNotification notification) +{ + var valueFromSaving = notification.State["SomeKey"]; +} +``` + +# Registering notification handlers + +Once you've made your notification handlers, you need to register them with the `AddNotificationHandler` extension method on the `IUmbracoBuilder`. This enables them to run whenever a notification they subscribe to is published. There are two ways to do this: + +1. In the **Startup** class, if you're making handlers for your site +2. In a [**composer**](../../implementation/composing.md), if you're a package developer subscribing to notifications + +## Registering notification handlers in the startup class + +In the Startup class, register your notification handler in the `ConfigureServices` after `AddComposers()` but before `Build()`: + +```csharp +public void ConfigureServices(IServiceCollection services) +{ +#pragma warning disable IDE0022 // Use expression body for methods + services.AddUmbraco(_env, _config) + .AddBackOffice() + .AddWebsite() + .AddComposers() + .AddNotificationHandler() + .Build(); +#pragma warning restore IDE0022 // Use expression body for methods + +} +``` + +The extension method takes two generic type parameters. The first, `ContentPublishingNotification`, is the notification you wish to subscribe to. The second, `DontShout`, is the class that handles the notification. This class must implement `INotificationHandler<>` with the type of notification it handles as the generic type parameter. In this case, the `DontShout` class definition looks like this: + +```csharp +public class DontShout : INotificationHandler +``` + +For the full handler implementation, see [ContentService Notifications](contentservice-notifications.md). + +## Registering notification handlers in a composer + +If you're writing a package for Umbraco you won't have access to the Startup class. You can instead use a composer, which gives you access to the `IUmbracoBuilder`. the rest is the same as when doing it in the Startup class: + +```csharp +public class DontShoutComposer : IComposer +{ + public void Compose(IUmbracoBuilder builder) + { + builder.AddNotificationHandler(); + } +} +``` + +## Registering many notification handlers + +You may want to subscribe to many notifications, meaning your `ConfigureServices` method or composer might become cluttered. You can avoid this by creating your own `IUmbracoBuilder` extension method for your events, keeping everything neatly wrapped up in one place, as follows: + +```csharp +using Umbraco.Cms.Core.DependencyInjection; +using Umbraco.Cms.Core.Services.Notifications; + +namespace MySite; + +public static class UmbracoBuilderNotificationExtensions +{ + public static IUmbracoBuilder AddDontShoutNotifications(this IUmbracoBuilder builder) + { + builder + .AddNotificationHandler() + .AddNotificationHandler() + .AddNotificationHandler(); + + return builder; + } +} +``` + +You can then register all these notifications by calling `AddDontShoutNotifications` in `ConfigureServices` or your composer, just like you would `AddNotificationHandler`: + +```csharp +public void ConfigureServices(IServiceCollection services) +{ +#pragma warning disable IDE0022 // Use expression body for methods + services.AddUmbraco(_env, _config) + .AddBackOffice() + .AddWebsite() + .AddComposers() + .AddDontShoutNotifications() + .Build(); +#pragma warning restore IDE0022 // Use expression body for methods + +} +``` + +Now, your handler will handle all the notifications you registered in your extension method. + +# Async Notification Handler + +If you need to do anything asynchronously when handling a notification, you can achieve this using the `INotificationAsyncHandler`. + +## Notification handler + +Create an asynchronous handler by implementing the `INotificationAsyncHandler`: + +```csharp +public class ContentDeletedHandler : INotificationAsyncHandler +{ + public async Task HandleAsync(ContentDeletedNotification notification, CancellationToken cancellationToken) + { + // await anything + await Task.Delay(1000); + } +} +``` + +### Notification registration + +When using the `INotificationAsyncHandler`, register it using the `IUmbracoBuilder` and the `AddNotificationAsyncHandler` extension method. This can be done in the Startup class or with a composer. + +#### Registering notification async handlers in the startup class + +Register your notification async handler to the `IUmbracoBuilder` in the Startup class: + +```csharp +public void ConfigureServices(IServiceCollection services) +{ + services.AddUmbraco(_env, _config) + .AddBackOffice() + .AddWebsite() + .AddComposers() + .AddNotificationAsyncHandler() + .Build(); +} +``` + +### Registering notification async handlers in a composer + +If you do not have access to the Startup class, use a composer instead: + +```csharp +public class NotificationHandlersComposer : IComposer +{ + public void Compose(IUmbracoBuilder builder) + { + builder.AddNotificationAsyncHandler(); + } +} +```