Skip to content

Instantly share code, notes, and snippets.

@mskutta
Created May 28, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mskutta/a617a2d9c70fda96680e to your computer and use it in GitHub Desktop.
Save mskutta/a617a2d9c70fda96680e to your computer and use it in GitHub Desktop.
EvaluateAction PublishItemProcessor
public class EvaluateAction : PublishItemProcessor
{
public override void Process(PublishItemContext context)
{
Assert.ArgumentNotNull(context, "context");
// We just want to process deletes because this is the only time the item being deleted may exist.
if (context.Action != PublishAction.DeleteTargetItem && context.Action != PublishAction.PublishSharedFields)
return;
// Attempt to find the item. If not found, item has already been deleted. This can occur when more than one langauge is published. The first language will delete the item.
var item = context.PublishHelper.GetTargetItem(context.ItemId) ??
context.PublishHelper.GetSourceItem(context.ItemId);
if (item == null)
return;
// Hold onto the item for the EvaluateResult PublishItemProcessor.
context.CustomData.Add("Item", item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment