I created an event on Umbraco 8 but the event is not fired ?
where do i need tu put my events so they can be trigged ?
this is my exampel code, i want this to be trigged on Published.
i have my code in APP_DATA
using System.Linq;
using Umbraco.Core;
using Umbraco.Web;
using Umbraco.Core.Composing;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Core.Logging;
namespace Extranet.Components
{
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public class ProjectComposer : IUserComposer
{
public void Compose(Composition composition)
{
}
}
public class ProjectComponent : IComponent
{
//inject in the core Logger service
private readonly ILogger _logger;
public ProjectComponent(ILogger logger)
{
_logger = logger;
}
public void Initialize()
{
ContentService.Published += this.ContentService_Published;
}
public void Terminate()
{
//unsubscribe during shutdown
// unsubscribe on shutdown
ContentService.Published -= ContentService_Published;
}
private void ContentService_Published(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.ContentPublishedEventArgs e)
{
// the custom code to fire everytime content is published goes here!
_logger.Info<ProjectComponent>("Something has been published...");
foreach (var publishedItem in e.PublishedEntities)
{
_logger.Info<ProjectComponent>(publishedItem.Name + " was published");
}
}
}
}
I created an event on Umbraco 8 but the event is not fired ?
where do i need tu put my events so they can be trigged ? this is my exampel code, i want this to be trigged on Published. i have my code in APP_DATA
Hi Wilmar
You need to register your component in the composer:
/Bjarne
Thanks :) !!
is working on a reply...