-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathContentSavedNotificationHandler.cs
More file actions
30 lines (24 loc) · 1.08 KB
/
Copy pathContentSavedNotificationHandler.cs
File metadata and controls
30 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
namespace DoStuff.Core.Notifications;
/// <summary>
/// Simple notification handler that runs when content is saved.
/// </summary>
/// <remarks>
/// the notification handler is registered in a composer (see BuilderNotificationHandlerExtension) and will run when the ContentSavedNotification is triggered in umbraco.
/// </remarks>
public class ContentSavedNotificationHandler : INotificationAsyncHandler<ContentSavedNotification>
{
public readonly ILogger<ContentSavedNotificationHandler> _logger;
public ContentSavedNotificationHandler(ILogger<ContentSavedNotificationHandler> logger)
{
_logger = logger;
}
public Task HandleAsync(ContentSavedNotification notification, CancellationToken cancellationToken)
{
if (_logger.IsEnabled(LogLevel.Information))
_logger.LogInformation("Notification: Content with Id {ContentId} has been saved", notification.SavedEntities.Select(x => x.Id));
return Task.CompletedTask;
}
}