Custom Decorator never gets fired
Hi,
I have a support ticket open for this, but no response as yet and thought i would crowd source. We have a custom module, and we would like to create a library (if one doesn't exist) on the publication of the custom item.
Issue we are facing is our custom decorator never gets called, and i am very unclear as to what is going wrong as there are no errors being generated, all the code i think is supposed to be there is, but still we can't seem to get it to run:
Decorator Code:
namespace LocationsModule.Helpers public class LocationDecorator: LifecycleDecorator public LocationDecorator(ILifecycleManager manager, LifecycleItemCopyDelegate copyDelegate, params Type[] itemTypes) : base(manager, copyDelegate, itemTypes) public LocationDecorator(ILifecycleManager manager, Action<Content, Content> copyDelegate, params Type[] itemTypes) : base(manager, copyDelegate, itemTypes) protected override ILifecycleDataItemGeneric ExecuteOnPublish(ILifecycleDataItemGeneric masterItem, ILifecycleDataItemGeneric liveItem, System.Globalization.CultureInfo culture = null, DateTime? publicationDate = null) var locItem = masterItem as LocationItem; var manager = LocationManager.GetManager(); if (locItem.AlbumId.ToString().IsNullOrEmpty()) var gcId = string.IsNullOrEmpty(locItem.ReferenceId) ? "" : " (" + locItem.ReferenceId + ")"; var albumName = "Gallery: USL " + locItem.Title + gcId; var album = LocationsHelper.GetAlbumByName(albumName); if (album == null) var albumId = Guid.NewGuid(); LocationsHelper.CreateAlbum(albumId, albumName); return base.ExecuteOnPublish(masterItem, liveItem, culture, publicationDate); protected void Application_Start(object sender, EventArgs e) Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized); void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e) Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<SelectorFields.PageSelector.PageSelectorFieldDialog>(); Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<Telerik.Sitefinity.Samples.SimpleImageSelectorDialog>(); ObjectFactory.Container.RegisterType<ILifecycleDecorator, LocationDecorator>(typeof(LocationManager).FullName, new InjectionConstructor( new InjectionParameter<ILifecycleManager>(null), new InjectionParameter<Action<Content, Content>>(null), new InjectionParameter<Type[]>(null))); Hi Roberto,
I am assuming that Locations module is a module created by using Module Builder. The registration of Decorator for Dynamic modules differs a little the regular ones. Below is a snippet
protected void Application_Start(object sender, EventArgs e) Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized); void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e) if (e.CommandName == "Bootstrapped") ObjectFactory.Container.RegisterType<ILifecycleDecorator, CustomDecorator.NewsDecorator> (typeof(DynamicModuleManager).FullName, new InjectionConstructor( new InjectionParameter<ILifecycleManager>(null), new InjectionParameter<LifecycleItemCopyDelegate>(null), new InjectionParameter<Type[]>(null) ) );