I am working on the following event system:
EventSystem.Subscribe<PublishTransaction, SaveEventArgs>(MyEventHandler, EventPhases.Initiated);
void MyEventHandler(PublishTransaction publishTransaction, SaveEventArgs saveEventArgs, EventPhases eventPhases)
{
IdentifiableObject identifiableObject = publishTransaction.Items[0];
if (identifiableObject.Id == "tcm:40-81620") //the test component
{
PublishContext publishContext = publishTransaction.PublishContexts[0];
log.DebugFormat(
"{0} - publishContext[0].ResolvedItems.Count = {1}; publishContext[0].ProcessedItems.Count = {2}",
publishTransaction.State.ToString(),
publishContext.ResolvedItems.Count,
publishContext.ProcessedItems.Count);
}
}
I need to do something with the resolved items, but I wasn't getting the behaviour I was expecting, so I decided to log the PublishTransactionState, ResolvedItems and ProcessedItems. In the handler I have set the code to run just for a single test component in order not to get logs for other transactions. The test component is being rendered with two templates.
Here is the log I get(using log4net):
WaitingForPublish - publishContext[0].ResolvedItems.Count = 0; publishContext[0].ProcessedItems.Count = 0
InProgress - publishContext[0].ResolvedItems.Count = 0; publishContext[0].ProcessedItems.Count = 0
Resolving - publishContext[0].ResolvedItems.Count = 0; publishContext[0].ProcessedItems.Count = 0
Rendering - publishContext[0].ResolvedItems.Count = 0; publishContext[0].ProcessedItems.Count = 0
Rendering - publishContext[0].ResolvedItems.Count = 0; publishContext[0].ProcessedItems.Count = 2
ReadyForTransport - publishContext[0].ResolvedItems.Count = 2; publishContext[0].ProcessedItems.Count = 2
ReadyForTransport - publishContext[0].ResolvedItems.Count = 2; publishContext[0].ProcessedItems.Count = 2
WaitingForDeployment - publishContext[0].ResolvedItems.Count = 2; publishContext[0].ProcessedItems.Count = 2
Success - publishContext[0].ResolvedItems.Count = 2; publishContext[0].ProcessedItems.Count = 2
Can someone please explain the following:
- Why is the 'PublishContext[0].ProcessedItems' populated prior to 'PublishContext[0].ResolvedItems?
- Why are there two 'Rendering' states? In question PublishTransaction save event triggered multiple times Rick Pannekoek states that "In general, the Save event is called for any save (change) of the PublishTransaction, not only for state changes" which is clear, however I can't seem to find out which property change is causing this. Is there an easy way to find out what is causing this save?
Thank you in advance
Why are there two 'Rendering' states?
isn't this because you're rendering two component presentations?