Documentation

AddStatusChangeHandler

void
CBPActivity::AddStatusChangeHandler(
 int event,
 IBPActivityEventListener eventHandler
);

This method adds a new event handler for modified activity status.

Method parameters

ParameterDescription
eventOne of the constants for CBPActivity::ExecutingEvent, CBPActivity::ClosedEvent, CBPActivity::FaultingEvent, that defines for which modification of status the event handler will be called.
eventHandlerEvent handler that realizes IBPActivityEventListener interface.

See Also

Examples

<?
class CBPMyActivity
extends CBPCompositeActivity // is inherited because it is a composite activity
implements IBPEventActivity // processing of descendant activity completion event
{
// Executed activity method
public function Execute()
{
// Get the first descendant activity
$activity = $this->arActivities[0];
// Subscribe to the status modification event for descendant activity (completion)
$activity->AddStatusChangeHandler(self::ClosedEvent, $this);
// Send a descendant activity for the runtime to execute
$this->workflow->ExecuteActivity($activity);

// Return a request to the runtime, specifying that the activity is still being executed
return CBPActivityExecutionStatus::Executing;
}

// Event handler for IBPEventActivity interface status modification
// This parameter passes an activity that modified the status
protected function OnEvent(CBPActivity $sender)
{
// Unsubscribe from the event, modifying the descendant activity status (completion)
$sender->RemoveStatusChangeHandler(self::ClosedEvent, $this);
// Descendant activity is completed, execute another code that we need
// For example, complete an activity
$this->workflow->CloseActivity($this);
}
}
?>


© «Bitrix24», 2001-2024
Up