CBPDocument::AutoStartWorkflows: Bitrix method

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

    
public static function AutoStartWorkflows($documentType$autoExecute$documentId$arParameters, &$arErrors)
    {
        
$arErrors = array();

        
$runtime CBPRuntime::GetRuntime();

        if (!
is_array($arParameters))
            
$arParameters = array($arParameters);

        if (!isset(
$arParameters[static::PARAM_TAGRET_USER]))
            
$arParameters[static::PARAM_TAGRET_USER] = is_object($GLOBALS["USER"]) ? "user_".intval($GLOBALS["USER"]->GetID()) : null;

        if (!isset(
$arParameters[static::PARAM_MODIFIED_DOCUMENT_FIELDS]))
            
$arParameters[static::PARAM_MODIFIED_DOCUMENT_FIELDS] = false;

        
$arParameters[static::PARAM_DOCUMENT_EVENT_TYPE] = $autoExecute;

        
$arWT CBPWorkflowTemplateLoader::SearchTemplatesByDocumentType($documentType$autoExecute);
        foreach (
$arWT as $wt)
        {
            try
            {
                
$wi $runtime->CreateWorkflow($wt["ID"], $documentId$arParameters);
                
$wi->Start();
            }
            catch (
Exception $e)
            {
                
$arErrors[] = array(
                    
"code" => $e->getCode(),
                    
"message" => $e->getMessage(),
                    
"file" => $e->getFile()." [".$e->getLine()."]"
                
);
            }
        }
    }