• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/lib/controller/debugger.php
  • Класс: BitrixBizprocControllerDebugger
  • Вызов: Debugger::resumeAutomationTemplateAction
public function resumeAutomationTemplateAction(string $sessionId)
{
	$session = $this->getSession($sessionId);

	if (!$session)
	{
		return null;
	}

	[$documentId, $documentType] = $this->getActiveDocument($session);

	if (!$documentId)
	{
		return null;
	}

	$currentState = Manager::getDebuggerState();

	if ($currentState->is(DebuggerState::RUN))
	{
		$newState = DebuggerState::pause();
	}
	else
	{
		$newState = DebuggerState::run();
	}

	Manager::setDebuggerState($newState);

	$documentService = CBPRuntime::GetRuntime(true)->getDocumentService();
	$automationTarget = $documentService->createAutomationTarget($documentType);
	$automationTarget->setDocumentId($documentId);

	$workflowId = $automationTarget->getRuntime()->getCurrentWorkflowId();
	$hasInstance = $workflowId && WorkflowInstanceTable::exists($workflowId);

	if ($hasInstance && $newState->is(DebuggerState::RUN))
	{
		/** @var DebugWorkflow $workflow */
		$workflow = CBPRuntime::GetRuntime(true)->getWorkflow($workflowId);
		$workflow->resume();
	}

	return [
		'workflowId' => $workflowId,
		'debuggerState' => $newState->getId(),
	];
}