CBPWorkflow::Start: Bitrix method

      
<?php 
//  CBPWorkflow :: Start()
//  /dist/bitrix/modules/bizproc/classes/general/workflow.php:186

    
public function Start()
    {
        if (
$this->GetWorkflowStatus() != CBPWorkflowStatus::Created)
            throw new 
Exception("CanNotStartInstanceTwice");

        
$this->isNew true;
        
$this->SetWorkflowStatus(CBPWorkflowStatus::Running);

        try
        {
            
$this->InitializeActivity($this->rootActivity);
            
$this->ExecuteActivity($this->rootActivity);
            
$this->RunQueue();
        }
        catch (
Exception $e)
        {
            
$this->Terminate($e);
            throw 
$e;
        }

        if (
$this->rootActivity->executionStatus == CBPActivityExecutionStatus::Closed)
        {
            
$this->SetWorkflowStatus(CBPWorkflowStatus::Completed);
        }
        else
        {
            
$workflowStatus $this->GetWorkflowStatus();
            if (
$workflowStatus == CBPWorkflowStatus::Running)
                
$this->SetWorkflowStatus(CBPWorkflowStatus::Suspended);
        }

        
$persister CBPWorkflowPersister::GetPersister();
        
$persister->SaveWorkflow($this->rootActivitytrue);
    }