• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/lib/controller/debugger.php
  • Класс: BitrixBizprocControllerDebugger
  • Вызов: Debugger::startSessionAction
public function startSessionAction(string $documentSigned, int $mode): ?array
{
	[$documentType, $documentCategoryId] = CBPDocument::unSignParameters($documentSigned);
	$userId = (int)$this->getCurrentUser()->getId();

	if (!Manager::canUserDebugAutomation($userId, $documentType))
	{
		$this->addError(new Error(Loc::getMessage('BIZPROC_CONTROLLER_DEBUGGER_CAN_DEBUG_ERROR')));

		return null;
	}

	$result = Manager::startSession($documentType, $mode, $userId, $documentCategoryId);
	if (!$result->isSuccess())
	{
		$this->addErrors($result->getErrorCollection()->toArray());

		return null;
	}

	/** @var Session $session */
	$session = $result->getObject();
	if ($session->getMode() === BitrixBizprocDebuggerSessionMode::EXPERIMENTAL)
	{
		$documentId = $this->createExperimentalDocument($documentType, $documentCategoryId);
		if (!$documentId)
		{
			Manager::finishSession($session);
			$this->addError(new Error(Loc::getMessage('BIZPROC_CONTROLLER_DEBUGGER_NO_DOCUMENT')));

			return null;
		}

		return $this->fixateSessionDocumentAction($documentId);
	}

	return [
		'documentSigned' => CBPDocument::signParameters([$documentType]),
		'session' => $session->toArray(),
	];
}