MarkClosed: Bitrix method

      
<?php 
//  MarkClosed()
//  /dist/bitrix/modules/bizproc/classes/general/activity.php:1197

    
private function MarkClosed($arEventParameters = array())
    {
        switch (
$this->executionStatus)
        {
            case 
CBPActivityExecutionStatus::Executing:
            case 
CBPActivityExecutionStatus::Canceling:
            case 
CBPActivityExecutionStatus::Faulting:
            {
                if (
is_subclass_of($this"CBPCompositeActivity"))
                {
                    foreach (
$this->arActivities as $activity)
                    {
                        if ((
$activity->executionStatus != CBPActivityExecutionStatus::Initialized
                            && (
$activity->executionStatus != CBPActivityExecutionStatus::Closed))
                        {
                            throw new 
Exception("ActiveChildExist");
                        }
                    }
                }

                
/** @var CBPTrackingService $trackingService */
                
$trackingService $this->workflow->GetService("TrackingService");
                
$trackingService->Write($this->GetWorkflowInstanceId(), CBPTrackingType::CloseActivity$this->name$this->executionStatus$this->executionResult, ($this->IsPropertyExists("Title") ? $this->Title ""));
                
$this->SetStatus(CBPActivityExecutionStatus::Closed$arEventParameters);

                return;
            }
        }

        throw new 
Exception("InvalidCloseActivityState");
    }