CBPRuntime::createDebugWorkflow

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPRuntime
  4. createDebugWorkflow
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/runtime.php
  • Класс: CBPRuntime
  • Вызов: CBPRuntime::createDebugWorkflow
public function createDebugWorkflow(int $templateId, array $documentId, $workflowParameters = [])
{
	$complexDocumentId = CBPHelper::ParseDocumentId($documentId);

	$workflowId = $workflowParameters[CBPDocument::PARAM_PRE_GENERATED_WORKFLOW_ID] ?? static::generateWorkflowId();
	$workflow = new DebugWorkflow($workflowId, $this);

	$loader = CBPWorkflowTemplateLoader::GetLoader();

	[$rootActivity, $workflowVariablesTypes, $workflowParametersTypes] = $loader->LoadWorkflow($templateId);

	if (is_null($rootActivity))
	{
		throw new Exception('Empty root activity');
	}

	foreach(GetModuleEvents("bizproc", "OnCreateWorkflow", true)  as $arEvent)
	{
		ExecuteModuleEventEx($arEvent, [$templateId, $documentId, &$workflowParameters, $workflowId]);
	}

	$workflow->Initialize(
		$rootActivity,
		$complexDocumentId,
		$workflowParameters,
		$workflowVariablesTypes,
		$workflowParametersTypes,
		$templateId
	);

	$starterUserId = 0;
	if (isset($workflowParameters[CBPDocument::PARAM_TAGRET_USER]))
	{
		$starterUserId = intval(mb_substr($workflowParameters[CBPDocument::PARAM_TAGRET_USER], mb_strlen("user_")));
	}

	$this
		->GetService("StateService")
		->AddWorkflow($workflowId, $templateId, $complexDocumentId, $starterUserId)
	;

	$this->workflows[$workflowId] = $workflow;

	return $workflow;
}

Добавить комментарий