Created
March 15, 2019 12:05
-
-
Save hartviglarsen/7f9299b790c169672650109157dcdd45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Linq; | |
| using Umbraco.Core; | |
| using Umbraco.Core.Composing; | |
| using Umbraco.Core.Events; | |
| using Umbraco.Core.Logging; | |
| using Umbraco.Core.Services; | |
| using Umbraco.Core.Services.Implement; | |
| namespace MvcCourse.Core | |
| { | |
| public class LetsLogComposer : IComposer | |
| { | |
| public void Compose(Composition composition) | |
| { | |
| composition.Components().Append<LetsLogComponent>(); | |
| } | |
| } | |
| public class LetsLogComponent : IComponent | |
| { | |
| private readonly ILogger _logger; | |
| public LetsLogComponent(ILogger logger) | |
| { | |
| _logger = logger; | |
| } | |
| public void Initialize() | |
| { | |
| ContentService.Published += ContentService_Published; | |
| } | |
| private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e) | |
| { | |
| _logger.Info<LetsLogComponent>($"You just published {e.PublishedEntities.Count()} item(s)!"); | |
| } | |
| public void Terminate() { } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment