CBPAllWorkflowPersister :: SaveWorkflow: Bitrix method

      
<?php 
//  CBPAllWorkflowPersister :: SaveWorkflow()
//  /dist/bitrix/modules/bizproc/classes/general/workflowpersister.php:178

    
public function SaveWorkflow(CBPActivity $rootActivity$bUnlocked)
    {
        if (
$rootActivity == null)
            throw new 
Exception("rootActivity");

        
$workflowStatus $rootActivity->GetWorkflowStatus();

        
$buffer "";
        if ((
$workflowStatus != CBPWorkflowStatus::Completed) && ($workflowStatus != CBPWorkflowStatus::Terminated))
            
$buffer $this->GetSerializedForm($rootActivity);

        
$creationData = [];
        if (
$rootActivity->workflow->isNew())
        {
            
$dt $rootActivity->GetDocumentId();
            
$creationData['MODULE_ID'] = $dt[0];
            
$creationData['ENTITY'] = $dt[1];
            
$creationData['DOCUMENT_ID'] = $dt[2];
            
$creationData['WORKFLOW_TEMPLATE_ID'] = $rootActivity->GetWorkflowTemplateId();
            
$creationData['STARTED_EVENT_TYPE'] = $rootActivity->getDocumentEventType();

            
$startedBy $rootActivity->{\CBPDocument::PARAM_TAGRET_USER};
            if (
$startedBy)
            {
                
$creationData['STARTED_BY'] = \CBPHelper::StripUserPrefix($startedBy);
            }
        }

        
$this->InsertWorkflow($rootActivity->GetWorkflowInstanceId(), $buffer$workflowStatus$bUnlocked$creationData);
    }