This file contains 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
namespace Feature.EventHandlers | |
{ | |
public class ClearAccessResultCache | |
{ | |
private static readonly Dictionary<ID, ID> TemplatesToCheck = new Dictionary<ID, ID>() | |
{ | |
{ Constants.Template1.TemplateId, Constants.Template1.Fields.Role }, | |
{ Constants.Template2.TemplateId, Constants.Template2.Fields.Role } | |
}; | |
public void OnItemSaved(object sender, EventArgs args) | |
{ | |
var savedItem = Event.ExtractParameter(args, 0) as Item; | |
var changes = Event.ExtractParameter(args, 1) as ItemChanges; | |
if (savedItem == null || changes == null || !TemplatesToCheck.ContainsKey(savedItem.TemplateID)) | |
return; | |
var fieldIdToCheck = TemplatesToCheck[savedItem.TemplateID]; | |
if (!changes.IsFieldModified(fieldIdToCheck)) | |
return; | |
// This is not optimal, but will do it for now | |
CacheManager.ClearAccessResultCache(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment