Last active
August 29, 2015 13:58
-
-
Save sniffdk/9931534 to your computer and use it in GitHub Desktop.
Fix re-publish of already published descendants in Umbraco
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
public class UmbracoHooks : IApplicationEventHandler | |
{ | |
private static readonly List<int> PublishFixes = new List<int>(); | |
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
ContentService.Publishing += (sender, args) => | |
{ | |
foreach (var contentItem in args.PublishedEntities) | |
{ | |
if (contentItem.HasPublishedVersion()) return; | |
lock (PublishFixes) | |
{ | |
if (!PublishFixes.Contains(contentItem.Id)) | |
{ | |
PublishFixes.Add(contentItem.Id); | |
} | |
} | |
} | |
}; | |
ContentService.Published += (sender, args) => | |
{ | |
foreach (var contentItem in args.PublishedEntities) | |
{ | |
lock (PublishFixes) | |
{ | |
if (!PublishFixes.Contains(contentItem.Id)) return; | |
library.RefreshContent(); | |
PublishFixes.Remove(contentItem.Id); | |
} | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment