I started event system code for my project, where I am getting Target Types for a Publication. Please suggest how to get the Publication Targets based on the Target Type:
My Requirement is : I need to unpublish the component based on the Expiration Date (Metadata field) while publishing the component. I am using following event (PublishEventArgs).
EventSystem.Subscribe<Component, PublishEventArgs>(OnComponentPublishPost, EventPhases.TransactionCommitted);
I am following below snippet code
private void OnComponentPublishPost(Component component, PublishEventArgs args, EventPhases phase)
{
foreach (PublishingTarget ty in args.Targets)
{
string targettype = ty.Id;
}
}
Here I am getting Target type (ty.id). In unpublishing method I need to pass the Publication Target(targets).
PublishEngine.UnPublish(items, unpublishInstruction, targets);
Please suggest how to get the Publication Targets.