CBPDocument::TerminateWorkflow: Bitrix method

      
<?php 
//  CBPDocument :: TerminateWorkflow()
//  /dist/bitrix/modules/bizproc/classes/general/document.php:435

    
public static function TerminateWorkflow($workflowId$documentId, &$arErrors$stateTitle '')
    {
        
$arErrors = array();

        
$runtime CBPRuntime::GetRuntime();

        try
        {
            
$workflow $runtime->GetWorkflow($workflowIdtrue);
            if (
$documentId)
            {
                
$d $workflow->GetDocumentId();
                if (
$d[0] != $documentId[0] || $d[1] != $documentId[1] || strtolower($d[2]) !== strtolower($documentId[2]))
                    throw new 
Exception(GetMessage("BPCGDOC_INVALID_WF"));
            }
            
$workflow->Terminate(null$stateTitle);
        }
        catch(
Exception $e)
        {
            
$arErrors[] = array(
                
"code" => $e->getCode(),
                
"message" => $e->getMessage(),
                
"file" => $e->getFile()." [".$e->getLine()."]"
            
);
            return 
false;
        }
        return 
true;
    }