I have a Umbraco 7 project which I would like to start customizing business logic within the events. I have created a class and used the following code from the documentation to get started. When I add a breakpoint to the 'Application Started' or 'Document Before publish' it never seems to get hit. Is there any additional requirements that I need to set or something that I have missed?
using Umbraco.Core;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic;
using umbraco.cms.businesslogic.web;
namespace Umbraco.Extensions.EventHandlers
{
public class RegisterEvents : ApplicationEventHandler
Umbraco Events not firing??
Hi,
I have a Umbraco 7 project which I would like to start customizing business logic within the events. I have created a class and used the following code from the documentation to get started. When I add a breakpoint to the 'Application Started' or 'Document Before publish' it never seems to get hit. Is there any additional requirements that I need to set or something that I have missed?
using Umbraco.Core;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic;
using umbraco.cms.businesslogic.web;
namespace Umbraco.Extensions.EventHandlers
{
public class RegisterEvents : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
Document.BeforePublish += Document_BeforePublish;
}
private void Document_BeforePublish(Document sender, PublishEventArgs e)
{
//Do what you need to do. In this case logging to the Umbraco log
Log.Add(LogTypes.Debug, sender.Id, "the document " + sender.Text + " is about to be published");
//cancel the publishing if you want.
e.Cancel = true;
}
}
}
Earvin,
In v7 you need to use content service to wire up events also in my code i am inheriting from IApplicationEventHandler see http://our.umbraco.org/documentation/Reference/Events-v6/ContentService-Events so you need:
}
Thanks! That worked perfectly.
Earvin,
Don't forget to mark as solution.
Regards
Ismail
is working on a reply...